-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
39 lines (32 loc) · 953 Bytes
/
Dockerfile
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
# Stage 1: Build the Vue app
FROM node:22.2.0 as client-builder
WORKDIR /app/client
COPY client/package*.json ./
RUN npm install
COPY client/ .
# Inject environment variables for Vue.js
ARG VITE_SUB_PATH
RUN echo "VITE_SUB_PATH=$VITE_SUB_PATH" > .env
RUN npm run build
# Stage 2: Build the Express server
FROM node:22.2.0 as server-builder
WORKDIR /app/server
COPY server/package*.json ./
RUN npm install
RUN npm install typescript
COPY server/ .
RUN npm run build
# Stage 3: Create the final image
FROM node:22.2.0-alpine
WORKDIR /app
COPY --from=server-builder /app/server/dist ./server/dist
COPY --from=client-builder /app/client/dist ./server/dist/views
COPY --from=client-builder /app/client/.env ./server/dist/views
COPY server/package*.json ./
RUN npm install
# Stage 4: Copy env-var bash script
COPY env.sh /app/env.sh
RUN chmod +x /app/env.sh
EXPOSE 3000
# Start the server
CMD ["/bin/sh", "-c", "./env.sh && node ./server/dist/app.js"]