-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
68 lines (47 loc) · 1.47 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
FROM node:18-buster-slim AS base
# default environment variables
ENV \
DEBIAN_FRONTEND=noninteractive \
TZ=UTC \
RS_URL=http://restreamer:8080
RUN \
# add dependencies
apt-get update \
&& apt-get install -y \
openssl \
procps \
tzdata \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
# create our own user and remove the node user
&& groupadd --gid 1001 app \
&& useradd --create-home --home /app --shell /bin/bash --gid 1001 --uid 1001 app \
&& userdel -r node \
# create the config directory
&& mkdir /config && chown app:app /config \
# install the latest version of npm
&& npm install -g npm@latest \
# create the node_modules directory, make it owned by app user
&& mkdir -p /app/node_modules && chown app:app /app/node_modules
USER app
WORKDIR /app
EXPOSE 3000
##############################
FROM base AS development
ENV NODE_ENV=development
COPY --chown=app:app package*.json ./
RUN npm ci --force && npm cache clean --force
CMD [ "npm", "run", "dev" ]
##############################
FROM development AS build
ENV NODE_ENV=production
COPY --chown=app:app . ./
RUN npm run build
##############################
FROM base AS production
ENV NODE_ENV=production
COPY --from=build --chown=app:app /app/.next ./.next
COPY --from=build --chown=app:app /app/public ./public
COPY --from=build --chown=app:app /app/node_modules ./node_modules
COPY --from=build --chown=app:app /app/package.json ./package.json
CMD [ "npm", "run", "start" ]