-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (46 loc) · 1.59 KB
/
Dockerfile
File metadata and controls
58 lines (46 loc) · 1.59 KB
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
55
56
57
58
FROM node:24.14.0-alpine as builder
# Create app directory
WORKDIR /app
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH
# set build version, date and revision
ARG ARG_BUILD_ENVIRONMENT=development
ARG ARG_BUILD_VERSION=dev
ARG ARG_BUILD_DATE
ARG ARG_BUILD_REVISION
ARG ARG_SENTRY_AUTH_TOKEN
ENV VITE_BUILD_VERSION=${ARG_BUILD_VERSION}
ENV VITE_BUILD_DATE=${ARG_BUILD_DATE}
ENV VITE_BUILD_REVISION=${ARG_BUILD_REVISION}
ENV SENTRY_AUTH_TOKEN=${ARG_SENTRY_AUTH_TOKEN}
# Install app dependencies
# A wildcard is used to ensure both package.json AND pnpm-lock.yaml are copied
# where available (pnpm)
COPY package*.json pnpm-lock.yaml ./
# Install pnpm globally
RUN npm i -g pnpm@10.17.1
RUN pnpm install
# Everything for now
COPY . .
# Conditionally run pnpm run build based on ARG_BUILD_ENVIRONMENT
RUN if [ "$ARG_BUILD_ENVIRONMENT" = "development" ]; then \
pnpm run-script build:dev; \
else \
pnpm run-script build:sentry; \
fi
FROM nginx:alpine as production-build
ARG ARG_BUILD_ENVIRONMENT=development
COPY ./.build/.nginx/nginx.conf /etc/nginx/nginx.conf
## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*
# Copy from the stage 1
COPY --from=builder /app/build /usr/share/nginx/html
WORKDIR /usr/share/nginx/html
RUN if [ "$ARG_BUILD_ENVIRONMENT" = "production" ]; then \
find /usr/share/nginx/html/assets -name "*.map" -type f -delete; \
fi
COPY --from=builder /app/.build/docker/env.sh .
COPY --from=builder /app/.build/docker/.env.base .
RUN chmod +x env.sh
EXPOSE 80
CMD ["/bin/sh", "-c", "/usr/share/nginx/html/env.sh && nginx -g \"daemon off;\""]