From 1d290c342a0d89e932fe8951abb940f8b998f003 Mon Sep 17 00:00:00 2001 From: Laurent Valdes Date: Sat, 21 Dec 2024 22:50:49 +0100 Subject: [PATCH] feat: provide docker build step --- .github/workflows/build-and-test.yml | 34 ++++++++++++++++------------ Dockerfile.click-persister | 2 +- Dockerfile.click-server | 1 + Dockerfile.tile-syncer-robot | 1 + Dockerfile.watchguard-robot | 1 + docker-compose.yml | 6 ++--- 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6a32e6d..75566f9 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -69,21 +69,25 @@ jobs: runs-on: ubuntu-latest steps: - # Step 1. Checkout the Repository - name: Checkout code uses: actions/checkout@v3 - # Step 2. Build Docker Images -# - name: Build Docker Images -# run: | -# docker-compose -f docker-compose.yml build - - # Step 3. Push Docker Images (Optional, only for main branch) -# - name: Push Docker Images -# if: github.ref == 'refs/heads/main' -# env: -# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} -# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} -# run: | -# echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin -# docker-compose -f docker-compose.yml push \ No newline at end of file + - name: Build Docker Images + run: | + docker compose -f docker-compose.yml build + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v4 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + run: | + docker compose -f docker-compose.yml push \ No newline at end of file diff --git a/Dockerfile.click-persister b/Dockerfile.click-persister index e5b26a3..e130170 100644 --- a/Dockerfile.click-persister +++ b/Dockerfile.click-persister @@ -26,7 +26,7 @@ RUN apt-get update && apt-get install -y \ libssl3 \ ca-certificates \ && rm -rf /var/lib/apt/lists/* - +LABEL org.opencontainers.image.source https://github.com/valdo404/clickplanet-rust COPY --from=builder /usr/src/app/target/release/state-click-persister ./ COPY countries.geojson \ diff --git a/Dockerfile.click-server b/Dockerfile.click-server index 989e020..3c2e222 100644 --- a/Dockerfile.click-server +++ b/Dockerfile.click-server @@ -21,6 +21,7 @@ RUN cargo build --release --bin click-server FROM debian:bookworm-slim WORKDIR /app +LABEL org.opencontainers.image.source https://github.com/valdo404/clickplanet-rust RUN apt-get update && apt-get install -y \ libssl3 \ diff --git a/Dockerfile.tile-syncer-robot b/Dockerfile.tile-syncer-robot index 9c29450..c0cba69 100644 --- a/Dockerfile.tile-syncer-robot +++ b/Dockerfile.tile-syncer-robot @@ -20,6 +20,7 @@ RUN cargo build --release --bin tile-syncer FROM debian:bookworm-slim WORKDIR /app +LABEL org.opencontainers.image.source https://github.com/valdo404/clickplanet-rust RUN apt-get update && apt-get install -y \ libssl3 \ diff --git a/Dockerfile.watchguard-robot b/Dockerfile.watchguard-robot index 0d62852..0693fa5 100644 --- a/Dockerfile.watchguard-robot +++ b/Dockerfile.watchguard-robot @@ -28,6 +28,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* COPY --from=builder /usr/src/app/target/release/country-watchguard ./ +LABEL org.opencontainers.image.source https://github.com/valdo404/clickplanet-rust COPY countries.geojson \ tile_to_countries.json \ diff --git a/docker-compose.yml b/docker-compose.yml index 771292c..7c0ea54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -55,7 +55,7 @@ services: build: context: ./ dockerfile: Dockerfile.click-server - image: clickplanet/click-server:latest + image: ghcr.io/valdo404/clickplanet-rust-state-click-server:latest environment: - RUST_LOG=debug command: [ @@ -80,7 +80,7 @@ services: build: context: ./ dockerfile: Dockerfile.click-persister - image: clickplanet/state-click-persister:latest + image: ghcr.io/valdo404/clickplanet-rust-state-click-persister:latest environment: - RUST_LOG=debug command: [ @@ -105,7 +105,7 @@ services: build: context: ./ dockerfile: Dockerfile.tile-syncer-robot - image: clickplanet/tile-syncer:latest + image: ghcr.io/valdo404/clickplanet-rust-tile-syncer:latest environment: - RUST_LOG=debug command: [