forked from nodecg/nodecg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
59 lines (40 loc) · 1.51 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
FROM node:18-slim AS build
WORKDIR /nodecg
COPY package.json package-lock.json ./
COPY scripts ./scripts
RUN npm ci
COPY tsconfig_base.json ./
COPY build-tools ./build-tools
COPY schemas ./schemas
COPY src ./src
RUN npm run build
FROM node:18-slim AS npm
WORKDIR /nodecg
COPY package.json package-lock.json ./
COPY scripts ./scripts
RUN npm ci --omit=dev
FROM node:18-slim AS runtime
RUN apt-get update \
&& apt-get install -y git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/nodecg
# Sets up the runtime user, makes nodecg-cli available to images which extend this image, and creates the directory structure with the appropriate permissions.
RUN addgroup --system nodecg \
&& adduser --system nodecg --ingroup nodecg \
&& npm i -g nodecg-cli \
&& mkdir cfg bundles logs db assets \
&& chown -R nodecg:nodecg /opt/nodecg
# Switch to the nodecg user
USER nodecg
COPY --chown=nodecg:nodecg package.json index.js ./
COPY --chown=nodecg:nodecg --from=npm /nodecg/node_modules ./node_modules
COPY --chown=nodecg:nodecg --from=build /nodecg/build ./build
COPY --chown=nodecg:nodecg --from=build /nodecg/scripts ./scripts
COPY --chown=nodecg:nodecg --from=build /nodecg/schemas ./schemas
# Define directories that should be persisted in a volume
VOLUME /opt/nodecg/cfg /opt/nodecg/bundles /opt/nodecg/logs /opt/nodecg/db /opt/nodecg/assets
# Define ports that should be used to communicate
EXPOSE 9090/tcp
# Define command to run NodeCG
# Using `node` directly is slightly faster than using `nodecg start`.
CMD ["node", "index.js"]