forked from microwavenby/shoegaze-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (53 loc) · 1.62 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
55
56
57
58
59
# -------- Image: base -------- #
# Base node image with package updates and dependencies
FROM node:18-slim as base
# Install openssl for Prisma
WORKDIR /srv
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
openssl
# -------- Image: deps -------- #
# Install all node_modules, including dev dependencies
FROM base as deps
COPY package.json package-lock.json ./
RUN npm install --production=false
# -------- Image: dev -------- #
# Provide a development image
FROM base as dev
COPY --from=deps /srv/node_modules /srv/node_modules
COPY prisma .
RUN npx prisma generate
COPY . .
CMD ["npm", "run", "dev:docker"]
# -------- Image: build -------- #
# Build the app
FROM base as build
COPY --from=deps /srv/node_modules /srv/node_modules
COPY prisma .
RUN npx prisma generate
COPY . .
RUN npm run build
RUN npm run css
# -------- Image: test -------- #
# Provide a test image
FROM build as test
ENV NODE_ENV test
CMD ["npm", "test"]
# -------- Image: production-deps -------- #
# Setup production node_modules
FROM base as production-deps
ENV NODE_ENV production
COPY --from=deps /srv/node_modules /srv/node_modules
COPY package.json package-lock.json ./
RUN npm prune --production
# -------- Image: prod -------- #
# Finally, build the production image with minimal footprint
FROM base as prod
ENV NODE_ENV production
COPY --from=production-deps /srv/node_modules /srv/node_modules
COPY --from=build /srv/node_modules/.prisma /srv/node_modules/.prisma
COPY --from=build /srv/build /srv/build
COPY --from=build /srv/styles/styles.* /srv/styles/
COPY --from=build /srv/public/build /srv/public/build
COPY . .
CMD ["/srv/bin/prod-start.sh"]