-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.prod
51 lines (42 loc) · 1.44 KB
/
Dockerfile.prod
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
FROM node:20-alpine3.18 as build
# Installing libvips-dev for sharp Compatibility
RUN apk update && apk add --no-cache git libc6-compat build-base gcc bash autoconf automake zlib-dev libpng-dev vips-dev > /dev/null 2>&1
ARG NODE_ENV=production
ARG STRAPI_PUBLIC_URL
ENV STRAPI_PUBLIC_URL=${STRAPI_PUBLIC_URL}
WORKDIR /opt/app
COPY ./package.json ./yarn.lock ./
ENV PATH /opt/app/node_modules/.bin:$PATH
RUN yarn global add patch-package node-gyp
COPY ./ .
# Build target dependencies #
#############################
FROM build AS dependencies
COPY ./patches /opt/app/patches
# Install prod dependencies
RUN yarn install --production=true --frozen-lockfile && \
# Cache prod dependencies
cp -R node_modules /prod_node_modules && \
# Install dev dependencies
yarn install --production=false
# Build target builder #
########################
FROM build AS builder
COPY --from=dependencies /opt/app/node_modules /opt/app/node_modules
COPY . /opt/app/
RUN yarn build && \
rm -rf node_modules
# Build target production #
###########################
FROM build AS production
COPY --from=builder /opt/app /opt/app
COPY --from=dependencies /prod_node_modules /opt/app/node_modules
RUN set -eux; \
chmod +x ./bin/wait-for-it.sh && \
addgroup --system --gid 1001 pdcgroup && \
adduser --system --uid 1001 --ingroup pdcgroup pdcuser && \
chown -R pdcuser:pdcgroup /opt/app
USER pdcuser
ENV NODE_ENV=${NODE_ENV}
EXPOSE 1337
CMD ["yarn" , "start"]