Skip to content

Commit

Permalink
Fix Dockerfiles + CI job for building and uploading docker images (#22)
Browse files Browse the repository at this point in the history
* fix: glibc in final docker images

* fix: pin rust image to major version based on debian

* fix: adjust compose file for new Dockerfile

* ci: public docker image on  repo tag

* ci: test pushing to own repo

* ci: fix

* ci: change image name

* ci: fix image name again

* ci: switch to upstream repo config

* refactor: ARG for final base image

* fix: switch to nonroot docker image
  • Loading branch information
gs-anssi committed Jan 10, 2025
1 parent 5d8cd52 commit 75a4e16
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 18 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,35 @@ jobs:
bin: diode-send,diode-receive,diode-send-file,diode-receive-file,diode-send-udp,diode-receive-udp
archive: lidi-$tag
token: ${{ secrets.GITHUB_TOKEN }}
build-and-push-docker-image:
name: Builds and pushes a tagged docker image
runs-on: ubuntu-latest
strategy:
matrix:
lidi_service:
- send
- receive
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: docker_meta
with:
images: docker.io/anssi/lidi-${{ matrix.lidi_service }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- uses: docker/build-push-action@v5
with:
context: .
push: true
target: ${{ matrix.lidi_service }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}


19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# NOTE: use Google's "distroless with libgcc1" base image, see:
# https://github.com/GoogleContainerTools/distroless/blob/6755e21ccd99ddead6edc8106ba03888cbeed41a/cc/README.md
ARG BASE_IMAGE_FINAL_STAGES="gcr.io/distroless/cc:nonroot"

FROM rust:1-bookworm AS builder

WORKDIR /usr/src/lidi
COPY . .
RUN cargo install --path .

FROM ${BASE_IMAGE_FINAL_STAGES} AS send

COPY --from=builder --chown=root:root --chmod=755 /usr/local/cargo/bin/diode-send /usr/local/bin/
ENTRYPOINT ["diode-send"]

FROM ${BASE_IMAGE_FINAL_STAGES} AS receive

COPY --from=builder --chown=root:root --chmod=755 /usr/local/cargo/bin/diode-receive /usr/local/bin/
ENTRYPOINT ["diode-receive"]
8 changes: 0 additions & 8 deletions Dockerfile.receive

This file was deleted.

8 changes: 0 additions & 8 deletions Dockerfile.send

This file was deleted.

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ services:
image: diode:send
build:
context: .
dockerfile: Dockerfile.send
dockerfile: Dockerfile
target: send
networks:
diode_net:
ipv4_address: 172.16.0.2
Expand All @@ -31,7 +32,8 @@ services:
image: diode:receive
build:
context: .
dockerfile: Dockerfile.receive
dockerfile: Dockerfile
target: receive
networks:
diode_net:
ipv4_address: 172.16.0.3
Expand Down

0 comments on commit 75a4e16

Please sign in to comment.