-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
executable file
·31 lines (28 loc) · 954 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Adapted from https://docs.strapi.io/dev-docs/installation/docker#production-dockerfile
# Creating multi-stage build for production
FROM node:20-alpine AS build
RUN apk update && apk add --no-cache build-base zlib-dev libpng-dev vips-dev > /dev/null 2>&1
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/app
COPY . .
RUN npm ci --include=dev
RUN npm run build
RUN npm prune --omit=dev
# Creating final production image
FROM node:20-alpine
RUN apk add --no-cache vips-dev
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
WORKDIR /opt/app
COPY --from=build /opt/app ./
RUN mv ./node_modules ../
# Also need to move the plugins folder so the node_modules workspace symlink is correct
RUN mv ./plugins ../
ENV PATH /opt/node_modules/.bin:$PATH
RUN mkdir -p /opt/app/database/migrations
RUN chown -R node:node /opt/app
USER node
EXPOSE 1337
# Avoiding NPM as it wants to read to /.npm/ which doesn't work in read-only
CMD ["strapi", "start"]