Skip to content

Commit

Permalink
opt: try adding support for custom UID/GID executions
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDark committed Oct 7, 2024
1 parent 02462dd commit 05437fb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md
FROM node:22.9.0-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PNPM_HOME="/opt/pnpm"
ENV COREPACK_HOME="/opt/corepack"
ENV PATH="$PNPM_HOME:$PATH"

RUN apt-get update && apt-get install -y \
git \
&& rm -rf /var/lib/apt/lists/* \
&& corepack enable \
&& corepack prepare pnpm@9 --activate
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY package.json pnpm-lock.yaml /app/

# Do it here to add the packageManager field to the package.json
RUN corepack enable \
&& corepack prepare pnpm@9 --activate \
&& corepack use pnpm@9

FROM base AS prod-deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile

FROM base
RUN corepack use pnpm@9
COPY --from=prod-deps /app/node_modules /app/node_modules
COPY index.ts /app/
COPY src/ /app/src/

ENV CONFIG_LOCATION=/app/config/config.yml
ENV SECRETS_LOCATION=/app/config/secrets.yml

RUN chmod uga+rw -R /app/package.json

#USER node

CMD [ "pnpm", "start" ]

0 comments on commit 05437fb

Please sign in to comment.