diff --git a/.dockerignore b/.dockerignore index f42174a..777e43d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,5 @@ node_modules dist *.log -.git .env .cache diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/deploy.yml similarity index 87% rename from .gitea/workflows/docker-build.yml rename to .gitea/workflows/deploy.yml index 85fb425..a5c29ab 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/deploy.yml @@ -33,7 +33,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - run: docker build --build-arg COMMIT_SHA=$(git rev-parse --short HEAD) -f apps/discord-bot/Dockerfile . + run: docker build -f apps/discord-bot/Dockerfile . deploy: runs-on: ubuntu-latest diff --git a/apps/discord-bot/Dockerfile b/apps/discord-bot/Dockerfile index 3867d9d..ef93b8c 100644 --- a/apps/discord-bot/Dockerfile +++ b/apps/discord-bot/Dockerfile @@ -1,5 +1,9 @@ -FROM node:22-alpine +FROM alpine AS git-sha +RUN apk add --no-cache git +COPY .git .git +RUN git rev-parse --short HEAD > /commit_sha +FROM node:22-alpine WORKDIR /app RUN corepack enable && corepack prepare pnpm@10.24.0 --activate @@ -15,7 +19,6 @@ RUN pnpm --filter @lbf-bot/utils run build RUN pnpm --filter @lbf-bot/database run build RUN pnpm --filter @lbf/discord-bot run build -ARG COMMIT_SHA=dev -ENV COMMIT_SHA=$COMMIT_SHA +COPY --from=git-sha /commit_sha /commit_sha -CMD ["node", "apps/discord-bot/dist/index.js"] +CMD export COMMIT_SHA=$(cat /commit_sha) && exec node apps/discord-bot/dist/index.js