main
text 65 lines 1.65 KB
Raw
1 # # Use a node.js base image
2 # FROM node:21 as builder
3
4 # # Install pnpm globally
5 # RUN npm install -g pnpm
6
7 FROM node:24 as builder
8 RUN corepack enable && corepack prepare pnpm@11.5.0 --activate
9
10 # Drop root
11 USER node
12
13 # Set the working directory
14 WORKDIR /app
15
16 # `pnpm-workspace.yaml` carries `allowBuilds` (required for @parcel/watcher native install).
17 COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
18
19 # Install project dependencies using pnpm
20 RUN pnpm install --frozen-lockfile
21
22 # Copy project files into the working directory
23 COPY --chown=node . .
24
25 # Run the Vue.js project build using pnpm
26 RUN pnpm run build:only
27
28 FROM node:24 as dev
29
30 RUN apt-get update && apt-get install -y openssl
31
32 RUN mkdir -p /certs & \
33 openssl req -x509 -subj "/CN=localhost" -nodes -newkey rsa:4096 -keyout /certs/key.pem -out /certs/cert.pem -days 365 && \
34 chown -R node:node /certs
35
36 # Drop root
37 USER node
38
39 # Set the working directory
40 WORKDIR /app
41
42 CMD pnpm install && pnpm run start-frontend
43
44 FROM nginx:1.30.0-alpine
45
46 # Added to create self-signed cert on run time if needed
47 RUN apk add openssl
48
49 # Set environment variables
50 ENV SERVER_HOST=localhost
51 ENV TLS_CERT_PATH=/etc/nginx/certs.d/server.crt
52 ENV TLS_KEY_PATH=/etc/nginx/certs.d/server.key
53
54 # Copy entrypoint
55 COPY build/docker-entrypoint.d/90-copilot-ssl.sh /docker-entrypoint.d/90-copilot-ssl.sh
56 RUN chmod +x /docker-entrypoint.d/90-copilot-ssl.sh
57
58 # Setup template
59 RUN mkdir /etc/nginx/templates
60 COPY build/etc/nginx/sites-enabled/default.conf /etc/nginx/templates/default.conf.template
61
62 # Copy built static files from the builder stage
63 COPY --from=builder /app/dist /var/www/copilot
64
65 CMD ["nginx", "-g", "daemon off;"]