-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (45 loc) · 1.46 KB
/
Dockerfile
File metadata and controls
62 lines (45 loc) · 1.46 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
### Multi-stage builds
# 1: Build the application
FROM node:25-alpine AS builder
# ENV vars
ARG VITE_BACKEND_PORT
ARG VITE_BACKEND_NAME
ARG VITE_APP_BACKEND_URL
ARG VITE_APP_VERSION
ENV VITE_BACKEND_PORT=${VITE_BACKEND_PORT}
ENV VITE_BACKEND_NAME=${VITE_BACKEND_NAME}
ENV VITE_APP_BACKEND_URL=${VITE_APP_BACKEND_URL}
ENV VITE_APP_VERSION=${VITE_APP_VERSION}
WORKDIR /build
COPY package*.json ./
RUN npm install --only=dev
COPY . .
RUN npm run build
# 2: Prepare the runtime environment
FROM alpine AS runner
# Install Node.js, npm, Nginx, envsubst
RUN apk add --no-cache nodejs npm nginx gettext \
&& mkdir -p /etc/nginx/templates \
&& mkdir -p /etc/nginx/conf.d
WORKDIR /app
# Copy build output and deps
COPY --from=builder /build/dist /app/dist
COPY --from=builder /build/node_modules /app/node_modules
COPY --from=builder /build/package.json /app/package.json
# Copy custom nginx.conf to replace default
COPY nginx.conf /etc/nginx/nginx.conf
# Copy Nginx template and entrypoint script
COPY nginx.template.conf /etc/nginx/templates/nginx.template.conf
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
# ENV vars
ARG VITE_BACKEND_PORT
ARG VITE_BACKEND_NAME
ARG VITE_APP_BACKEND_URL
ARG VITE_APP_VERSION
ENV VITE_BACKEND_PORT=${VITE_BACKEND_PORT}
ENV VITE_BACKEND_NAME=${VITE_BACKEND_NAME}
ENV VITE_APP_BACKEND_URL=${VITE_APP_BACKEND_URL}
ENV VITE_APP_VERSION=${VITE_APP_VERSION}
EXPOSE 5173
ENTRYPOINT ["/docker-entrypoint.sh"]