-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (40 loc) · 1.42 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Install dependencies only when needed
FROM node:16-alpine AS deps
# Install libvips-dev for sharp compatibility
# RUN apk add --no-cache install libvips-dev
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
# WORKDIR /app/strapi
# COPY /packages/strapi/package.json /packages/strapi/package-lock.json ./
# RUN npm ci
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
# COPY --from=deps /app/strapi/node_modules ./packages/strapi/node_modules
ENV NODE_ENV production
RUN npx nx run strapi:build
# Production image, copy all the files and run Strapi
FROM node:16-alpine AS runner
WORKDIR /app
COPY --from=builder /app/dist/packages/strapi ./strapi
COPY --from=deps /app/node_modules ./node_modules
COPY /packages/strapi/database ./strapi/database
COPY /packages/strapi/public ./strapi/public
COPY /packages/strapi/scripts ./strapi/scripts
COPY /packages/strapi/favicon.png ./strapi/favicon.png
COPY /packages/strapi/package.json ./strapi/package.json
COPY /tsconfig.base.json ./strapi
COPY /packages/strapi/.env ./strapi
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 strapi
# Only needed for SQLite db for demonstrating purposes
RUN mkdir ./strapi/packages/.tmp
RUN chown -R strapi ./strapi/packages/.tmp
USER strapi
EXPOSE 1337
ENV NODE_ENV production
WORKDIR /app/strapi
CMD ["node", "scripts/start.js"]