Fix docker image to allow subsequent pnpm setups (#23878)

This commit is contained in:
Pascal Jufer
2024-10-24 09:22:17 +02:00
committed by GitHub
parent 704d313c27
commit 646eb4dafa

View File

@@ -4,12 +4,8 @@
## Build Packages
FROM node:18-alpine AS builder
WORKDIR /directus
ARG TARGETPLATFORM
ENV NODE_OPTIONS=--max-old-space-size=8192
RUN <<EOF
if [ "$TARGETPLATFORM" = 'linux/arm64' ]; then
apk --no-cache add python3 build-base
@@ -17,13 +13,22 @@ RUN <<EOF
fi
EOF
WORKDIR /directus
COPY package.json .
RUN corepack enable && corepack prepare
# Deploy as 'node' user to match pnpm setups in production image
# (see https://github.com/directus/directus/issues/23822)
RUN chown node:node .
USER node
ENV NODE_OPTIONS=--max-old-space-size=8192
COPY pnpm-lock.yaml .
RUN pnpm fetch
COPY . .
COPY --chown=node:node . .
RUN <<EOF
pnpm install --recursive --offline --frozen-lockfile
npm_config_workspace_concurrency=1 pnpm run build
@@ -49,8 +54,6 @@ USER node
WORKDIR /directus
EXPOSE 8055
ENV \
DB_CLIENT="sqlite3" \
DB_FILENAME="/directus/database/database.sqlite" \
@@ -60,6 +63,8 @@ ENV \
COPY --from=builder --chown=node:node /directus/ecosystem.config.cjs .
COPY --from=builder --chown=node:node /directus/dist .
EXPOSE 8055
CMD : \
&& node cli.js bootstrap \
&& pm2-runtime start ecosystem.config.cjs \