-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
82 lines (55 loc) · 2.25 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
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright (C) 2022-present Wong Chun Yat (wcyat)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM node:18-alpine AS build
ARG REACT_APP_build
ENV REACT_APP_build $REACT_APP_build
ARG REACT_APP_date
ENV REACT_APP_date $REACT_APP_date
ARG REACT_APP_version
ENV REACT_APP_version $REACT_APP_version
ARG env
ENV env $env
ENV REACT_APP_ENV $env
WORKDIR /app
COPY ./package.json ./yarn.lock ./tsconfig.json ./postcss.config.js ./tailwind.config.js ./
RUN chown -Rf node:node /app
USER node
RUN yarn install --frozen-lockfile --network-timeout 1000000
COPY ./src ./src
COPY ./public ./public
COPY ./scripts ./scripts
COPY ./.babelrc ./config-overrides.js ./
RUN if [ "${env}" != "dev" ]; then yarn build && rm -rf node_modules && mkdir node_modules; fi;
RUN if [ "${env}" != "dev" ]; then rm -rf tsconfig.json yarn.lock .babelrc config-overrides.js postcss.config.js tailwind.config.js; fi;
FROM node:18-alpine
WORKDIR /app
ARG REACT_APP_build
ENV REACT_APP_build $REACT_APP_build
ARG REACT_APP_date
ENV REACT_APP_date $REACT_APP_date
ARG REACT_APP_version
ENV REACT_APP_version $REACT_APP_version
ARG env
ENV env $env
ENV REACT_APP_ENV $env
COPY --from=build /app/build* ./build
COPY --from=build /app/node_modules ./node_modules
COPY ./scripts ./scripts
COPY --from=build /app/package.json /app/yarn.lock* /app/tsconfig.json* /app/.babelrc* /app/config-overrides.js* /app/postcss.config.js* /app/tailwind.config.js* ./
COPY ./serve.json ./
RUN if [ "${env}" != "dev" ]; then yarn global add serve --network-timeout 1000000; fi;
RUN chown -f node:node /app /app/node_modules && if [ -d /app/build ]; then chown -Rf node:node /app/build; fi;
USER node
CMD yarn start