-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (39 loc) · 1.65 KB
/
Dockerfile
File metadata and controls
52 lines (39 loc) · 1.65 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
# Stage 1: Build the React application
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:22-bookworm AS builder
# Set working directory
WORKDIR /app
# Copy package.json and pnpm lockfile
COPY package.json pnpm-lock.yaml ./
# Ensure pnpm is available
RUN npm install -g pnpm@10.28.2
# Install project dependencies
RUN pnpm install --frozen-lockfile
# Copy the rest of the application code
COPY . .
# Set placeholder values for REACT_APP_* env vars so CRA inlines them
# into the JS bundle. At container startup, env.sh replaces these
# placeholder strings with real values from the container environment.
ENV REACT_APP_WEB_CLIENT_ID=APP_WEB_CLIENT_ID \
REACT_APP_WEB_AUTHORITY=APP_WEB_AUTHORITY \
REACT_APP_REDIRECT_URL=APP_REDIRECT_URL \
REACT_APP_POST_REDIRECT_URL=APP_POST_REDIRECT_URL \
REACT_APP_WEB_SCOPE=APP_WEB_SCOPE \
REACT_APP_API_SCOPE=APP_API_SCOPE \
REACT_APP_API_BASE_URL=APP_API_BASE_URL \
REACT_APP_AUTH_ENABLED=APP_AUTH_ENABLED \
REACT_APP_CONSOLE_LOG_ENABLED=APP_CONSOLE_LOG_ENABLED
# Build the application
RUN pnpm build
# Stage 2: Serve the application with NGINX
FROM mcr.microsoft.com/azurelinux/base/nginx:1.25
# Copy the built files from the previous stage
COPY --from=builder /app/build /usr/share/nginx/html
#https://mcr.microsoft.com/en-us/artifact/mar/azurelinux/base/nginx/about
COPY /nginx-custom.conf /etc/nginx/nginx.conf
COPY env.sh /docker-entrypoint.d/env.sh
RUN chmod +x /docker-entrypoint.d/env.sh
RUN sed -i 's/\r$//' /docker-entrypoint.d/env.sh
# Expose the application port
EXPOSE 3000
# Start NGINX and run env.sh
CMD ["/bin/sh", "-c", "/docker-entrypoint.d/env.sh && nginx -g 'daemon off;'"]