-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
62 lines (45 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
54
55
56
57
58
59
60
61
62
# Based on:
# https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
# Install dependencies
FROM node:19-alpine3.16 AS deps
USER node
WORKDIR /home/node
RUN mkdir app # So it is owned by node
COPY app/package*.json app/
WORKDIR /home/node/app
RUN npm ci
# Build source code
FROM deps AS builder
USER node
WORKDIR /home/node/app
COPY --chown=node:node app .
RUN npm run build
# Common for production & development deployments
FROM node:19-alpine3.16 AS runner-common
LABEL maintainer="Specify Collections Consortium <github.com/specify>"
RUN apk add --no-cache mariadb-client
USER node
WORKDIR /home/node
RUN mkdir state
COPY --chown=node:node state state
RUN mkdir nginx.conf.d
# Development image
FROM runner-common AS dev-runner
USER node
RUN mkdir /home/node/app
WORKDIR /home/node/app
ENV NODE_ENV=development
COPY docker-entrypoint.sh ../
ENTRYPOINT ["../docker-entrypoint.sh"]
# Production image, copy all files and run next
FROM runner-common AS runner
USER node
WORKDIR /home/node/app
ENV NODE_ENV=production
COPY --from=builder /home/node/app/next.config.js ./
COPY --from=builder /home/node/app/public ./public
COPY --from=builder /home/node/app/.next ./.next
COPY --from=builder /home/node/app/node_modules ./node_modules
COPY --from=builder /home/node/app/package.json ./package.json
COPY --from=builder /home/node/app/.env.local ./.env.local
CMD ["npm", "run", "start"]