-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
42 lines (29 loc) · 1 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
ARG NODE_VERSION=20
# Use the official Node.js image as the builder stage.
# "alpine" refers to a lightweight Linux distribution based on musl libc and BusyBox,
# known for its small size and efficiency.
FROM node:$NODE_VERSION-alpine AS builder
ARG COMMIT_HASH
ENV DIR /var/www
COPY . $DIR/
RUN ls -la $DIR
# build dirs
RUN mkdir -p $DIR/builds/application
WORKDIR $DIR
COPY package*.json $DIR/
RUN npm ci --production --unsafe-perm --ignore-scripts .
# global variables
# RUN echo "REACT_APP_GIT_COMMIT_HASH=$COMMIT_HASH" > .env.local
# remove storybook files
RUN find src -type f -name "*.stories.tsx" -delete
RUN npm run build
RUN mv $DIR/build/* $DIR/builds/application/
FROM nginx:stable-alpine
ADD nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /var/www/builds /var/www
COPY --from=builder /var/www/env.* /var/www
COPY --from=builder /var/www/package.json /var/www/package.json
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD nginx -g 'daemon off;'