From 3f6404cd3fd86df5a95358eedfb841b52033fd9b Mon Sep 17 00:00:00 2001 From: kekkon Date: Thu, 21 Nov 2024 20:22:05 +0100 Subject: [PATCH 1/3] Update dockerignore file --- .dockerignore | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 352d3cf..1660601 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,8 +7,13 @@ *.db *.db-shm *.db-wal +*.http +/*.json +dist-workspace.toml +justfile +release.toml -.github -.devcontainer -.testdata +.github/ +.devcontainer/ +.testdata/ .run/ \ No newline at end of file From 99c7e419316529bf28267c4b8d2da5c09a569e09 Mon Sep 17 00:00:00 2001 From: kekkon Date: Thu, 21 Nov 2024 20:43:09 +0100 Subject: [PATCH 2/3] Docker build as PR check --- .github/workflows/pr-checks.yml | 1 - Docker/Dockerfile | 16 +++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 4a083ac..6fb255f 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -11,7 +11,6 @@ name: PR Checks on: pull_request: - # The branches below must be a subset of the branches above branches: [ "main" ] types: [ready_for_review, opened, synchronize] diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 23ce190..8254943 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,7 +1,10 @@ ARG APP_NAME=fercord +ARG EXEC_NAME=fercord_bot +ARG VARIANT="bookworm" -FROM rust:1-slim-bullseye AS builder +FROM rust:1-slim-${VARIANT} AS builder ARG APP_NAME +ARG EXEC_NAME RUN USER=root cargo new --bin ${APP_NAME} WORKDIR /${APP_NAME} COPY . . @@ -10,13 +13,13 @@ RUN apt-get update \ && apt-get install -y ca-certificates tzdata pkg-config libssl-dev \ && rm -rf /var/lib/apt/lists/* -RUN cargo build --bin fercord_bot --release --locked -RUN rm -rf fercord_storage/**.rs fercord_bot/**.rs +RUN cargo build --bin ${EXEC_NAME} --release --locked +RUN rm -rf fercord_storage/**.rs ${EXEC_NAME}/**.rs fercord_common/**.rs ADD . ./ RUN rm ./target/release/deps/${APP_NAME}* -RUN cargo build --bin fercord_bot --release --locked +RUN cargo build --bin ${EXEC_NAME} --release --locked -FROM debian:bullseye-slim AS runner +FROM debian:${VARIANT}-slim AS runner RUN apt-get update \ && apt-get install -y ca-certificates tzdata \ && rm -rf /var/lib/apt/lists/* @@ -26,7 +29,6 @@ ARG UID=1001 RUN adduser \ --disabled-password \ --gecos "" \ - --home "/nonexistent" \ --shell "/sbin/nologin" \ --no-create-home \ --uid "${UID}" \ @@ -42,7 +44,7 @@ ENV TZ=Etc/UTC \ RUST_LOG="info,sqlx::query=warn" WORKDIR /app -COPY --from=builder /${APP_NAME}/target/release/fercord_bot ./${APP_NAME} +COPY --from=builder /${APP_NAME}/target/release/${EXEC_NAME} ./${APP_NAME} RUN chown -R $APP_USER:$APP_USER /app From 46f839f3c10ef455b24feeae03d47b300ba1ae89 Mon Sep 17 00:00:00 2001 From: kekkon Date: Thu, 21 Nov 2024 20:49:25 +0100 Subject: [PATCH 3/3] Don't run changelog check if no packages are updated --- .github/workflows/pr-checks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 6fb255f..1bb31ea 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -52,10 +52,13 @@ jobs: printf "Changes to code detected: %s" $code_or_cargo_changed >> $GITHUB_STEP_SUMMARY - uses: swatinem/rust-cache@v2 + if: ${{ steps.check_relevant_changes.outputs.code_or_cargo_changed == 'true' }} - name: Install Rust toolchain + if: ${{ steps.check_relevant_changes.outputs.code_or_cargo_changed == 'true' }} uses: dtolnay/rust-toolchain@stable - name: Verify if CHANGELOG is updated + if: ${{ steps.check_relevant_changes.outputs.code_or_cargo_changed == 'true' }} run: | # Extract a list of modified workspace packages workspace_root=$(cargo metadata --format-version 1 --no-deps | jq -r '.workspace_root')