Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improve dockerfiles and build in ci #24

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading