From 2ba268f709a14df2d051c12de10894859f8a8976 Mon Sep 17 00:00:00 2001 From: ari Date: Tue, 25 Mar 2025 22:38:44 +0100 Subject: [PATCH] chore: clean up dockerfile (#606) --- Dockerfile | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index af8149f..c4d189b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,46 @@ # syntax=docker/dockerfile:1 FROM node:22-alpine3.20 AS builder -WORKDIR /build -# install python etc so node-gyp works for the optional dependencies + +# install required depencencies for node-gyp RUN apk add --no-cache make gcc g++ python3 -# install pnpm to make dependency installation faster (because it has a lockfile) + RUN npm install -g pnpm -COPY package.json pnpm-lock.yaml ./ + +WORKDIR /build + COPY --link scripts scripts RUN chmod +x ./scripts/start.sh -# install dependencies, CI=true to skip pre/postinstall scripts + +COPY package.json pnpm-lock.yaml ./ + RUN CI=true pnpm install --prod --frozen-lockfile + COPY --link . . FROM node:22-alpine3.20 AS runner -RUN apk --no-cache add curl \ - && adduser --disabled-password --home /home/container container \ - && mkdir /app \ +LABEL org.opencontainers.image.source=https://github.com/discord-tickets/bot \ + org.opencontainers.image.description="The most popular open-source ticket bot for Discord." \ + org.opencontainers.image.licenses="GPL-3.0-or-later" + +RUN apk --no-cache add curl + +RUN adduser --disabled-password --home /home/container container +RUN mkdir /app \ && chown container:container /app \ && chmod -R 777 /app + USER container ENV USER=container \ HOME=/home/container \ NODE_ENV=production \ HTTP_HOST=0.0.0.0 \ DOCKER=true + WORKDIR /home/container + COPY --from=builder --chown=container:container --chmod=777 /build /app + ENTRYPOINT [ "/app/scripts/start.sh" ] HEALTHCHECK --interval=15s --timeout=5s --start-period=60s \ CMD curl -f http://localhost:${HTTP_PORT}/status || exit 1 -LABEL org.opencontainers.image.source=https://github.com/discord-tickets/bot \ - org.opencontainers.image.description="The most popular open-source ticket bot for Discord." \ - org.opencontainers.image.licenses="GPL-3.0-or-later"