-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
38 lines (29 loc) · 1.05 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
#
# First stage: build the app
#
FROM node:16.15.1 AS builder
WORKDIR /app
# Install pnpm
RUN npm install --global pnpm@8
# pnpm fetch does require only lockfile
COPY pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm fetch
COPY . ./
RUN pnpm --filter-prod @taxi/web... install --offline && \
pnpm --filter-prod @taxi/web... build
#
# Second stage: serve the app
#
FROM nginx:1.26.3-alpine
# Set default environment variables
ENV REACT_APP_BACK_URL=https://taxi.sparcs.org/api \
REACT_APP_FRONT_URL=https://taxi.sparcs.org \
REACT_APP_OG_URL=https://og-image.taxi.sparcs.org
# Install node & react-inject-env
RUN apk add --no-cache nodejs npm && \
npm install --global react-inject-env@2.1.0
COPY --from=builder /app/packages/web/build /app/build/
COPY serve /app/serve/
RUN chmod +x /app/serve/
EXPOSE 80
CMD ["sh", "-c", "envsubst '$$REACT_APP_FRONT_URL $$REACT_APP_OG_URL' < /app/serve/default.conf.template > /etc/nginx/conf.d/default.conf && npx react-inject-env set -d /app/build/ && nginx -g 'daemon off;'"]