-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
70 lines (56 loc) · 1.26 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
ARG APP_ROOT=/opt/app-root/src
ARG BASE_IMAGE=docker.io/node:20.9.0-alpine
#
# Build the app
#
FROM ${BASE_IMAGE} as app
ARG APP_ROOT
ENV NO_UPDATE_NOTIFIER=true
# NPM Permission Fix
RUN mkdir -p /.npm
RUN chown -R 1001:0 /.npm
# Build App
COPY app ${APP_ROOT}
RUN chown -R 1001:0 ${APP_ROOT}
USER 1001
WORKDIR ${APP_ROOT}
RUN npm ci && npm run build
#
# Build the frontend
#
FROM ${BASE_IMAGE} as frontend
ARG APP_ROOT
ENV NO_UPDATE_NOTIFIER=true
# NPM Permission Fix
RUN mkdir -p /.npm
RUN chown -R 1001:0 /.npm
# Build Frontend
COPY frontend ${APP_ROOT}
RUN chown -R 1001:0 ${APP_ROOT}
USER 1001
WORKDIR ${APP_ROOT}
RUN npm ci && npm run build
#
# Create the final container image
#
FROM ${BASE_IMAGE}
ARG APP_ROOT
ENV APP_PORT=8080 \
NO_UPDATE_NOTIFIER=true
# NPM Permission Fix
RUN mkdir -p /.npm
RUN chown -R 1001:0 /.npm
# Install File Structure
COPY --from=app ${APP_ROOT}/sbin ${APP_ROOT}/sbin
COPY --from=frontend ${APP_ROOT}/dist ${APP_ROOT}/dist
COPY .git ${APP_ROOT}/.git
COPY app/config ${APP_ROOT}/config
COPY app/config ${APP_ROOT}/sbin/config
COPY app/package.json app/package-lock.json ${APP_ROOT}
WORKDIR ${APP_ROOT}
# Install Application
RUN chown -R 1001:0 ${APP_ROOT}
USER 1001
RUN npm ci --omit=dev
EXPOSE ${APP_PORT}
CMD ["node", "./sbin/bin/www"]