-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Dockerfile
70 lines (47 loc) · 1.83 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
FROM node:20.12.2-bookworm-slim AS assets
LABEL maintainer="Nick Janetakis <nick.janetakis@gmail.com>"
WORKDIR /app/frontend
ARG UID=1000
ARG GID=1000
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean \
&& groupmod -g "${GID}" node && usermod -u "${UID}" -g "${GID}" node \
&& mkdir -p /node_modules && chown node:node -R /node_modules /app
USER node
COPY --chown=node:node frontend/package.json frontend/*yarn* ./
RUN yarn install && yarn cache clean
ARG NODE_ENV="production"
ENV NODE_ENV="${NODE_ENV}" \
PATH="${PATH}:/node_modules/.bin" \
USER="node"
COPY --chown=node:node . ..
RUN if [ "${NODE_ENV}" != "development" ]; then \
../run yarn:build:js && ../run yarn:build:css; else mkdir -p /app/public; fi
CMD ["bash"]
###############################################################################
FROM node:20.12.2-bookworm-slim AS app
LABEL maintainer="Nick Janetakis <nick.janetakis@gmail.com>"
WORKDIR /app/backend
ARG UID=1000
ARG GID=1000
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl libpq-dev \
&& rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man \
&& apt-get clean \
&& groupmod -g "${GID}" node && usermod -u "${UID}" -g "${GID}" node \
&& mkdir -p /node_modules && chown node:node -R /node_modules /app
USER node
COPY --chown=node:node backend/package.json backend/*yarn* ./
RUN yarn install && yarn cache clean
ARG NODE_ENV="production"
ENV NODE_ENV="${NODE_ENV}" \
PATH="${PATH}:/node_modules/.bin" \
USER="node"
COPY --chown=node:node --from=assets /app/public /public
COPY --chown=node:node backend/ ./
COPY --chown=node:node bin/ /app/bin
ENTRYPOINT ["/app/bin/docker-entrypoint-web"]
EXPOSE 8000
CMD ["yarn", "watch-production"]