-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
38 lines (26 loc) · 926 Bytes
/
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
FROM node:18.15.0-bullseye AS dependency
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install project dependencies
COPY . .
RUN yarn install
# Validate typescript is correct
RUN node_modules/.bin/tsc
# Generate a production build to serve statically
RUN yarn build
# Add script to inject REACT_APP_* env vars into index.html
COPY scripts/injectEnv.js /usr/src/app/build/injectEnv.js
# Serve build dist statically via nginx
FROM nginx
# Install nodejs (needed for injectEnv.js script)
# TODO: this could be improved by rewriting it in bash
COPY --from=dependency /usr/local /usr/local
COPY --from=dependency /usr/lib /usr/lib
WORKDIR /usr/src/app
# Copy nginx config and static files
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=dependency /usr/src/app/build /usr/share/nginx/html
# Move entrypoint script to image
COPY ./entrypoint.sh ./entrypoint.sh
EXPOSE 80
ENTRYPOINT [ "./entrypoint.sh" ]