-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
78 lines (70 loc) · 2.46 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# syntax=docker/dockerfile:1.3
FROM node:20-bullseye-slim AS base-version
FROM base-version AS build-deps
# RUN apt-get update -yqq && apt-get install -yqq build-essential python3 make g++ dpkg curl bash git
# Install dependencies only when needed
FROM build-deps AS dev-deps
WORKDIR /app
COPY package.json yarn.lock .npmr[c] ./
ENV NODE_ENV=development
RUN yarn install --frozen-lockfile
FROM build-deps AS prod-deps
WORKDIR /app
COPY package.json yarn.lock .npmr[c] ./
ENV NODE_ENV=production
RUN yarn install --frozen-lockfile
# Install dependencies only when needed
FROM base-version AS base
WORKDIR /app
RUN apt-get update -yqq && \
apt-get install -yqq bash curl && \
mkdir -p /app/secrets && \
chown -R node:node /app
FROM base AS dev
USER node
ENV NEXT_TELEMETRY_DISABLED="1" \
NODE_ENV=development \
HOST="0.0.0.0" \
HTTPS=true \
TZ=UTC
COPY --chown=node:node --from=dev-deps /app/node_modules ./node_modules
COPY --chown=node:node public ./public
COPY --chown=node:node pages ./pages
COPY --chown=node:node styles ./styles
COPY --chown=node:node components ./components
COPY --chown=node:node .env.loca[l] *r[c] *.j[s] *.jso[n] *.yam[l] *.m[d] *.loc[k] ./
RUN NODE_ENV=development ./node_modules/.bin/next build
COPY --chown=node:node scripts ./scripts
CMD ["yarn", "dev"]
FROM base as production-build
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED="1"
COPY --chown=node:node --from=dev-deps /app/node_modules ./node_modules
COPY --chown=node:node .env.loca[l] *rc *.js *.json *.yaml *.md *.lock ./
COPY --chown=node:node public ./public
COPY --chown=node:node pages ./pages
COPY --chown=node:node styles ./styles
COPY --chown=node:node components ./components
RUN NODE_ENV=production ./node_modules/.bin/next build
FROM base AS production
WORKDIR /app
USER node
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED="1" \
HOST="0.0.0.0" \
PORT=3003 \
TZ=UTC
COPY --chown=node:node --from=prod-deps /app/node_modules ./node_modules
COPY --chown=node:node .env.loca[l] *rc *.js *.json *.yaml *.md *.lock ./
COPY --chown=node:node next.config.js ./
COPY --chown=node:node public ./public
COPY --chown=node:node scripts ./scripts
COPY --chown=node:node styles ./styles
COPY --chown=node:node pages ./pages
COPY --chown=node:node components ./components
COPY --from=production-build --chown=node:node /app/.next/standalone ./
COPY --from=production-build --chown=node:node /app/.next/static ./.next/static
EXPOSE 3003
VOLUME ["/app/secrets"]
CMD ["node", "server.js"]