-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (44 loc) · 1.63 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (44 loc) · 1.63 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-alpine AS builder
ARG NODE_ENV=production
ARG APP_ENV=production
ARG BUILD_TARGET=azure
ARG NPM_TOKEN
ARG SENTRY_DSN=""
ARG SENTRY_AUTH_TOKEN=""
ARG GA_TRACKING_CODE=""
# VITE_API_URL, VITE_IDP_URL come from committed .env.development / .env.production
# SENTRY_AUTH_TOKEN: build-only; enables Vite sourcemaps + Sentry upload (see vite.config.ts)
ENV NODE_ENV=${NODE_ENV} \
APP_ENV=${APP_ENV} \
BUILD_TARGET=${BUILD_TARGET} \
NPM_TOKEN=${NPM_TOKEN} \
SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} \
VITE_SENTRY_DSN=${SENTRY_DSN} \
VITE_GA_TRACKING_CODE=${GA_TRACKING_CODE} \
HUSKY=0
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN apk add --no-cache libc6-compat
RUN set -eux; \
TOKEN="$(printf %s "${NPM_TOKEN:-}" | tr -d '\r\n')"; \
test -n "$TOKEN" || { echo "error: build-arg NPM_TOKEN is required for @oacore (GitHub Packages)." >&2; exit 1; }; \
printf '%s\n' '@oacore:registry=https://npm.pkg.github.com' "//npm.pkg.github.com/:_authToken=${TOKEN}" > .npmrc; \
corepack enable; \
corepack prepare pnpm@9 --activate; \
NODE_ENV=development pnpm install --frozen-lockfile; \
rm -f .npmrc
COPY . .
RUN case "$APP_ENV" in \
staging) pnpm run build:staging ;; \
development) pnpm run build:dev ;; \
production) pnpm run build ;; \
*) pnpm run build ;; \
esac
FROM nginx:1.27-alpine AS runtime
WORKDIR /usr/share/nginx/html
RUN rm -rf /usr/share/nginx/html/* \
&& rm -f /etc/nginx/conf.d/default.conf
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 8080
CMD ["nginx", "-g", "daemon off;"]