Slim Docker runtime image
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 2m44s

This commit is contained in:
Kroonk
2026-05-20 17:42:52 +02:00
parent c9919479bf
commit e8c1e3539d
3 changed files with 84 additions and 16 deletions

View File

@@ -1,7 +1,4 @@
FROM node:lts-bookworm-slim
# Install git and stockfish (native binary)
RUN apt-get update && apt-get install -y --no-install-recommends git stockfish && rm -rf /var/lib/apt/lists/*
FROM node:lts-bookworm-slim AS build
ENV PNPM_HOME=/usr/local/bin
@@ -9,21 +6,46 @@ WORKDIR /opt/michess/
COPY . .
RUN corepack enable && \
corepack prepare pnpm@9.15.9 --activate && \
pnpm config set store-dir /opt/michess/.pnpm-store && \
pnpm install --no-frozen-lockfile
# Build-time env vars for Next.js (baked into the frontend bundle)
ARG NEXT_PUBLIC_API_URL=http://localhost:3001
ARG NEXT_PUBLIC_APP_URL=http://localhost:3000
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_APP_URL=$NEXT_PUBLIC_APP_URL
# Build server and client
RUN pnpm build:server && pnpm build:client
RUN corepack enable && \
corepack prepare pnpm@9.15.9 --activate && \
pnpm config set store-dir /opt/michess/.pnpm-store && \
pnpm install --no-frozen-lockfile && \
pnpm build:server && \
pnpm build:client && \
rm -rf node_modules client/node_modules server/node_modules types/node_modules && \
pnpm install --prod --no-frozen-lockfile && \
pnpm store prune && \
rm -rf \
/opt/michess/.pnpm-store \
/root/.cache \
/tmp/* \
client/.next/cache \
client/src \
server/src \
.git \
.github \
.gitea
FROM node:lts-bookworm-slim
RUN apt-get update && \
apt-get install -y --no-install-recommends stockfish && \
rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production
ENV PNPM_HOME=/usr/local/bin
WORKDIR /opt/michess/
COPY --from=build /opt/michess/ ./
RUN corepack enable && corepack prepare pnpm@9.15.9 --activate
EXPOSE 3000 3001
ENTRYPOINT ["pnpm"]
CMD ["start"]
CMD ["node", "scripts/start-production.mjs"]