-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
53 lines (38 loc) · 1.39 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
FROM node:18-alpine AS dependencies
WORKDIR /srv/app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
USER node
########################################################
FROM node:18-alpine AS builder
ARG NODE_ENV
ENV NODE_ENV ${NODE_ENV}
WORKDIR /srv/app
COPY . .
COPY --from=dependencies /srv/app/node_modules ./node_modules
RUN npx prisma generate
RUN yarn build
# NextJS seems to have no intentions on supporting a
# different cache dir. They do seem to approve symlinking though
# https://github.com/vercel/next.js/discussions/35656
# https://github.com/vercel/next.js/issues/10111
# Note this is kind of dangerous, as it relies on /srv/data being the
# mount point of the volume!!
RUN rm -rf ./.next/cache
RUN ln -s /srv/data/next-cache ./.next/cache
################################################################
FROM node:18-alpine AS runner
USER 1000
WORKDIR /srv/app
ENV NODE_ENV production
COPY --from=builder /srv/app/node_modules ./node_modules
COPY --from=builder /srv/app/package.json ./
COPY --from=builder /srv/app/next.config.js ./
COPY --from=builder /srv/app/prisma ./
COPY --from=builder /srv/app/public ./public
COPY --from=builder /srv/app/.next ./.next
EXPOSE 3000
# Start directly via next, since yarn requires
# Filesystem write access to run a command. In production
# environments this may be problematic
CMD [ "node_modules/.bin/next", "start", "-H", "0.0.0.0" ]