mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Brainslug <br41nslug@users.noreply.github.com> Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
67 lines
1.6 KiB
Docker
67 lines
1.6 KiB
Docker
# syntax=docker/dockerfile:1.4
|
|
|
|
####################################################################################################
|
|
## 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
|
|
ln -sf /usr/bin/python3 /usr/bin/python
|
|
fi
|
|
EOF
|
|
|
|
COPY package.json .
|
|
RUN corepack enable && corepack prepare
|
|
|
|
COPY pnpm-lock.yaml .
|
|
RUN pnpm fetch
|
|
|
|
COPY . .
|
|
RUN <<EOF
|
|
pnpm install --recursive --offline --frozen-lockfile
|
|
npm_config_workspace_concurrency=1 pnpm run build
|
|
pnpm --filter directus deploy --prod dist
|
|
cd dist
|
|
# Regenerate package.json file with essential fields only
|
|
# (see https://github.com/directus/directus/issues/20338)
|
|
node -e '
|
|
const f = "package.json", {name, version, type, exports, bin} = require(`./${f}`), {packageManager} = require(`../${f}`);
|
|
fs.writeFileSync(f, JSON.stringify({name, version, type, exports, bin, packageManager}, null, 2));
|
|
'
|
|
mkdir -p database extensions uploads
|
|
EOF
|
|
|
|
####################################################################################################
|
|
## Create Production Image
|
|
|
|
FROM node:18-alpine AS runtime
|
|
|
|
RUN npm install --global pm2@5
|
|
|
|
USER node
|
|
|
|
WORKDIR /directus
|
|
|
|
EXPOSE 8055
|
|
|
|
ENV \
|
|
DB_CLIENT="sqlite3" \
|
|
DB_FILENAME="/directus/database/database.sqlite" \
|
|
NODE_ENV="production" \
|
|
NPM_CONFIG_UPDATE_NOTIFIER="false"
|
|
|
|
COPY --from=builder --chown=node:node /directus/ecosystem.config.cjs .
|
|
COPY --from=builder --chown=node:node /directus/dist .
|
|
|
|
CMD : \
|
|
&& node cli.js bootstrap \
|
|
&& pm2-runtime start ecosystem.config.cjs \
|
|
;
|