-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile-local
45 lines (38 loc) · 1.78 KB
/
Dockerfile-local
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
FROM public.ecr.aws/docker/library/node:20-alpine as staticbuilder
# Copy files needed for downloading dependencies
COPY ./package.json /builder/package.json
COPY ./yarn.lock /builder/yarn.lock
WORKDIR /builder
# The sources are not copied yet, so this step is cached between different builds
# with modified sources, as long as the files above have not changed.
RUN yarn && yarn cache clean --force
# Copy the sources and build the app.
# Changes in other files won't invalidate the cached build.
COPY ./src /builder/src
COPY ./public /builder/public
COPY ./tsconfig.json /builder/tsconfig.json
COPY ./tsconfig.eslint.json /builder/tsconfig.eslint.json
COPY ./.eslintrc.js /builder/.eslintrc.js
RUN REACT_APP_DISABLE_SENTRY=1 yarn build
FROM public.ecr.aws/docker/library/nginx:1.22.1
# Install mods for nginx that include the Headers More mod, that allows the
# removal of the Server -header
RUN apt-get update && apt-get --no-install-recommends install -y nginx-extras && apt-get clean
EXPOSE 8000
COPY --from=staticbuilder ./builder/build /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
# Copy default environment config and setup script
# Copy package.json so env.sh can read it
COPY ./scripts/env.sh /opt/env.sh
COPY .env /opt/.env
COPY package.json /opt/package.json
RUN chmod +x /opt/env.sh
#COPY ./nginx/variables.conf /etc/nginx/templates/10-variables.conf.template
# Copy script that injects environment variables to nginx.conf
COPY ./scripts/nginx-env.sh /opt/nginx-env.sh
# The script copies /opt/nginx.conf to /etc/nginx/nginx.conf
# while replacing the environment variables
COPY ./nginx/nginx.conf /opt/nginx.conf
RUN chmod +x /opt/nginx-env.sh
ENV REACT_APP_DISABLE_SENTRY=1
CMD ["/bin/bash", "-c", "/opt/env.sh /opt /usr/share/nginx/html && /opt/nginx-env.sh && nginx -g \"daemon off;\""]