-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (53 loc) · 2.38 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (53 loc) · 2.38 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
59
60
61
62
63
64
65
66
67
68
69
# ============================================================
# STAGE 1: Build the Static Assets
# ============================================================
FROM helsinki.azurecr.io/ubi9/nodejs-24-pnpm-builder-base AS appbase
# 1. Copy needed files for build
COPY --chown=default:root package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY --chown=default:root ./scripts ./scripts
COPY --chown=default:root ./public ./public
COPY --chown=default:root ./cities ./cities
COPY --chown=default:root ./assets ./assets
# 2. Run the install and update-runtime-env script
# corepack in the base image will automatically use the version of pnpm
# defined in your package.json 'packageManager' field if present.
RUN pnpm install --frozen-lockfile --ignore-scripts && pnpm store prune
RUN pnpm update-runtime-env
# 3. Copy remaining source files
COPY --chown=default:root index.html vite.config.mjs eslint.config.mjs .prettierrc .env* ./
COPY --chown=default:root ./src ./src
# ============================================================
# STAGE 2: Development
# ============================================================
FROM appbase AS development
# Set working directory, node environment, and expose port for development server
WORKDIR /app
ENV NODE_ENV=development
EXPOSE 8080
# Start the development server
CMD pnpm exec vite --port 8080
# ============================================================
# STAGE 3: Static builder for production
# ============================================================
FROM appbase AS staticbuilder
# Perform the build
ARG REACT_APP_SENTRY_RELEASE
RUN pnpm build
# ============================================================
# STAGE 4: Production Runtime
# ============================================================
FROM helsinki.azurecr.io/ubi10/nginx-126-spa-standard AS production
ARG REACT_APP_SENTRY_RELEASE
ENV APP_RELEASE=${REACT_APP_SENTRY_RELEASE:-""}
# 1. Copy the compiled assets
COPY --from=staticbuilder /app/build /usr/share/nginx/html
# 2. Setup Runtime Env Injection
# env.sh is provided by the base image
WORKDIR /usr/share/nginx/html
COPY .env .
# 3. Inject Versioning for the /readiness endpoint from package.json using base image
COPY package.json .
# - env.sh (Inherited from base image at /usr/share/nginx/html/env.sh)
# - USER 1001 (Inherited from base image)
# - EXPOSE 8080 (Inherited from base image)
# - ENTRYPOINT/CMD (Inherited from base image)