-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add docker image for the backend.
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build & Push Backend Container | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v*" | ||
|
||
env: | ||
RELEASE_VERSION: ${{ github.ref_name }} | ||
|
||
jobs: | ||
build-and-publish: | ||
name: Build and Publish Container | ||
runs-on: ubuntu-latest | ||
env: | ||
DEPLOY_HOOK: ${{ secrets.DEPLOY_HOOK }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
ghcr.io/${{ github.repository }}-backend | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: "{{defaultContext}}:backend" | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM messense/rust-musl-cross:x86_64-musl as build | ||
COPY . /home/rust/src | ||
RUN cargo build --release | ||
|
||
FROM scratch | ||
COPY --from=build /home/rust/src/target/x86_64-unknown-linux-musl/release/backend /backend | ||
ENTRYPOINT ["/backend"] |