-
Notifications
You must be signed in to change notification settings - Fork 6
/
web.Dockerfile
55 lines (42 loc) · 1.08 KB
/
web.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
###
## React App
###
FROM node:16-bullseye-slim AS nodebuilder
# Add a work directory
WORKDIR /app
# Cache and Install dependencies
COPY package.json .
COPY tsconfig.json .
COPY yarn.lock .
# Install
RUN yarn install --frozen-lockfile --network-timeout 1000000
# Copy app files
COPY craco.config.ts .
# eslint
COPY .eslintrc.json .
COPY .eslintignore .
# prettier
COPY .prettierrc.json .
COPY .prettierignore .
# Add folders
COPY src ./src
COPY public ./public
# Build the app
RUN yarn build
###
## Caddy Web Server & Run proxy binary
###
FROM caddy:alpine as production
# Add your Caddyfile
COPY Caddyfile /etc/caddy/Caddyfile
# Copy built assets from builder
COPY --from=nodebuilder /app/build /usr/share/caddy/html
WORKDIR /patch
# Add the script to patch window with ENV vars
# https://create-react-app.dev/docs/title-and-meta-tags#injecting-data-from-the-server-into-the-page
COPY web-entrypoint.sh .
RUN chmod +x /patch/web-entrypoint.sh
# Expose port
EXPOSE 8080
ENTRYPOINT ["/patch/web-entrypoint.sh"]
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]