Skip to content

Commit

Permalink
Fix Dockerfile and add CI check (#520)
Browse files Browse the repository at this point in the history
* Fix Dockerfile

Added resources that were missing the for docker context.
Added explicit dockerhub reference.

* Add workflow for docker image build

This commit represents a workflow variant without pushing to the
registry, references #517

* Remove wrong comment from workflow

* Apply suggestions from code review on #520

Co-authored-by: Uwe Klotz <[email protected]>

* Use release tags instead of commit shas in workflow

---------

Co-authored-by: Sandro Eiler <[email protected]>
Co-authored-by: Uwe Klotz <[email protected]>
  • Loading branch information
3 people authored Apr 2, 2024
1 parent 5dce844 commit 263e1d5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build-container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: Build a Docker image

on:
push:
branches:
- main

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-image:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
24 changes: 18 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ARG BUILD_BIN=${PROJECT_NAME}
# 1st Build Stage
# The tag of the base image must match the version in the file rust-toolchain!
# Available images can be found at https://hub.docker.com/r/clux/muslrust/tags/
FROM clux/muslrust:stable AS build
FROM docker.io/clux/muslrust:stable AS build

# Import global ARGs
ARG WORKDIR_ROOT
Expand Down Expand Up @@ -57,6 +57,8 @@ RUN USER=root cargo new --lib ofdb-application \
&& \
USER=root cargo new --lib ofdb-entities \
&& \
USER=root cargo new --lib ofdb-frontend-api \
&& \
USER=root cargo new --lib ofdb-gateways \
&& \
USER=root cargo new --lib ofdb-webserver
Expand Down Expand Up @@ -84,6 +86,9 @@ COPY [ \
COPY [ \
"ofdb-entities/Cargo.toml", \
"./ofdb-entities/" ]
COPY [ \
"ofdb-frontend-api/Cargo.toml", \
"./ofdb-frontend-api/" ]
COPY [ \
"ofdb-gateways/Cargo.toml", \
"./ofdb-gateways/" ]
Expand All @@ -110,6 +115,8 @@ RUN cargo build --${BUILD_MODE} --target ${BUILD_TARGET} --workspace \
&& \
rm -f ./target/${BUILD_TARGET}/${BUILD_MODE}/deps/ofdb_entities-* \
&& \
rm -f ./target/${BUILD_TARGET}/${BUILD_MODE}/deps/ofdb_frontend_api-* \
&& \
rm -f ./target/${BUILD_TARGET}/${BUILD_MODE}/deps/ofdb_gateways-* \
&& \
rm -f ./target/${BUILD_TARGET}/${BUILD_MODE}/deps/ofdb_webserver-* \
Expand All @@ -136,9 +143,6 @@ RUN cargo build --${BUILD_MODE} --target ${BUILD_TARGET} --workspace \
COPY [ \
"openapi.yaml", \
"./" ]
COPY [ \
"migrations", \
"./migrations/" ]
COPY [ \
"ofdb-app-clearance", \
"./ofdb-app-clearance/" ]
Expand All @@ -154,15 +158,21 @@ COPY [ \
COPY [ \
"ofdb-db-sqlite/src", \
"./ofdb-db-sqlite/src/" ]
COPY [ \
"ofdb-db-sqlite/migrations", \
"./ofdb-db-sqlite/migrations/" ]
COPY [ \
"ofdb-db-tantivy/src", \
"./ofdb-db-tantivy/src/" ]
COPY [ \
"ofdb-entities/src", \
"./ofdb-entities/src/" ]
COPY [ \
"ofdb-gateways/src", \
"./ofdb-gateways/src/" ]
"ofdb-frontend-api/src", \
"./ofdb-frontend-api/src/" ]
COPY [ \
"ofdb-gateways", \
"./ofdb-gateways/" ]
COPY [ \
"ofdb-webserver/build.rs", \
"./ofdb-webserver/build.rs" ]
Expand All @@ -186,6 +196,8 @@ RUN cargo check --${BUILD_MODE} --target ${BUILD_TARGET} --package ofdb-applicat
&& \
cargo check --${BUILD_MODE} --target ${BUILD_TARGET} --package ofdb-entities \
&& \
cargo check --${BUILD_MODE} --target ${BUILD_TARGET} --package ofdb-frontend-api \
&& \
cargo check --${BUILD_MODE} --target ${BUILD_TARGET} --package ofdb-gateways \
&& \
cargo check --${BUILD_MODE} --target ${BUILD_TARGET} --package ofdb-webserver \
Expand Down

0 comments on commit 263e1d5

Please sign in to comment.