generated from DTS-STN/next-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
98 lines (79 loc) · 2.17 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# FROM node:16-alpine AS base
# RUN apk add --no-cache libc6-compat
# WORKDIR /base
# COPY package.json yarn.lock ./
# COPY . .
# #
# #
# FROM base AS build
# ENV NODE_ENV=production
# WORKDIR /build
# COPY --from=base /base ./
# RUN yarn install
# RUN yarn build
# #
# #
# FROM node:16-alpine AS production
# ENV NODE_ENV=production
# SHELL ["/bin/sh", "-c"]
# RUN apk add --no-cache bash
# ARG user=joker
# ARG home=/home/node
# ARG group=thejokers
# RUN addgroup -S $group
# RUN adduser \
# --disabled-password \
# --gecos "" \
# --home $home \
# --ingroup $group \
# $user
# ENV NODE_ENV=production
# WORKDIR $home
# COPY --from=build --chown=55:$group /build/next.config.js ./
# COPY --from=build --chown=55:$group /build/package.json ./
# COPY --from=build --chown=55:$group /build/yarn.lock ./yarn.lock
# COPY --from=build --chown=55:$group /build/.yarn ./.yarn
# COPY --from=build --chown=55:$group /build/.next ./.next
# COPY --from=build --chown=55:$group /build/public ./public
# RUN VERSION_NEXT=`node -p -e "require('./package.json').dependencies.next"`&& yarn add next@"$VERSION_NEXT"
# USER $user
# CMD [ "yarn", "start" ]
FROM node:16.15.1-alpine AS production
ENV NODE_ENV=production
SHELL ["/bin/sh", "-c"]
RUN apk add --no-cache bash
ARG user=joker
ARG home=/home/node
ARG group=thejokers
ARG ADOBE_ANALYTICS_URL
ARG LOGGING_LEVEL
ARG NEXTAUTH_URL
ARG NEXTAUTH_SECRET
ARG NEXT_AUTH_USERNAME
ARG NEXT_AUTH_PASSWORD
ARG APP_ENV
ARG NEXT_BUILD_DATE
RUN addgroup -S $group
RUN adduser \
--disabled-password \
--gecos "" \
--home $home \
--ingroup $group \
$user
ENV APP_ENV=$APP_ENV
ENV ADOBE_ANALYTICS_URL=$ADOBE_ANALYTICS_URL
ENV LOGGING_LEVEL=$LOGGING_LEVEL
ENV NEXTAUTH_URL=$NEXTAUTH_URL
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
ENV NEXT_AUTH_USERNAME=$NEXT_AUTH_USERNAME
ENV NEXT_AUTH_PASSWORD=$NEXT_AUTH_PASSWORD
ENV NEXT_BUILD_DATE=$NEXT_BUILD_DATE
WORKDIR $home
COPY --chown=55:$group . .
RUN yarn install --immutable
RUN yarn build
COPY --chown=55:$group public ./public
RUN VERSION_NEXT=`node -p -e "require('./package.json').dependencies.next"`&& yarn add next@"$VERSION_NEXT"
USER $user
EXPOSE 3000
CMD [ "yarn", "start" ]