Skip to content

Commit

Permalink
build: add docker image for the backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed May 25, 2024
1 parent c9c6584 commit 5d2feca
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/build-backend.yaml
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
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
7 changes: 7 additions & 0 deletions backend/Dockerfile
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"]

0 comments on commit 5d2feca

Please sign in to comment.