-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
62 lines (49 loc) · 1.04 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
ARG APP_ROOT=/opt/app-root/src
ARG BASE_IMAGE=docker.io/node:20.17.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 --omit=dev
#
# 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 app/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} ${APP_ROOT}
COPY --from=frontend ${APP_ROOT}/dist ${APP_ROOT}/frontend/dist
COPY .git ${APP_ROOT}/.git
WORKDIR ${APP_ROOT}
EXPOSE ${APP_PORT}
CMD ["node", "./bin/www"]