@cryptotaxi247 / CoPilot / commits / 70f347af

Refactor Dockerfile to remove unnecessary stages and streamline the build process

taylorwalton committed Nov 30, 2025 at 10:18 UTC 70f347af63e2763a9531e1c5847187b5b9fe2b31
1 file changed +19 -43
customer_portal/Dockerfile
+19 -43
@@ -1,62 +1,38 @@
1 -# Use a node.js base image
2 -FROM node:21 as builder
1 +# Build stage
2 +FROM node:21 AS builder
3
4 # Install pnpm globally
5 RUN npm install -g pnpm
6
7 -# Drop root
8 -USER node
9 -
7 # Set the working directory
8 WORKDIR /app
9
13 -# Copy the package.json and pnpm-lock.yaml files into the working directory
14 -COPY package.json pnpm-lock.yaml ./
10 +# Copy package files
11 +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
12
16 -# Install project dependencies using pnpm
17 -RUN pnpm install
13 +# Install project dependencies
14 +RUN pnpm install --frozen-lockfile
15
19 -# Copy project files into the working directory
20 -COPY --chown=node . .
16 +# Copy all source files
17 +COPY . .
18
22 -# Run the Vue.js project build using pnpm
19 +# Build the application
20 RUN pnpm run build:only
21
25 -FROM node:21 as dev
26 -
27 -RUN apt-get update && apt-get install -y openssl
28 -
29 -RUN mkdir -p /certs & \
30 - openssl req -x509 -subj "/CN=localhost" -nodes -newkey rsa:4096 -keyout /certs/key.pem -out /certs/cert.pem -days 365 && \
31 - chown -R node:node /certs
32 -
33 -# Drop root
34 -USER node
35 -
36 -# Set the working directory
37 -WORKDIR /app
38 -
39 -CMD pnpm install && pnpm run start-frontend
40 -
22 +# Production stage
23 FROM nginx:1.24.0-alpine
24
43 -# Added to create self-signed cert on run time if needed
44 -RUN apk add openssl
45 -
46 -# Set environment variables
47 -ENV SERVER_HOST=localhost
48 -ENV TLS_CERT_PATH=/etc/nginx/certs.d/server.crt
49 -ENV TLS_KEY_PATH=/etc/nginx/certs.d/server.key
25 +# Copy custom nginx config
26 +COPY nginx.conf /etc/nginx/nginx.conf
27
51 -# Copy entrypoint
52 -COPY build/docker-entrypoint.d/90-copilot-ssl.sh /docker-entrypoint.d/90-copilot-ssl.sh
53 -RUN chmod +x /docker-entrypoint.d/90-copilot-ssl.sh
28 +# Copy built static files from builder stage
29 +COPY --from=builder /app/dist /usr/share/nginx/html
30
55 -# Setup template
56 -RUN mkdir /etc/nginx/templates
57 -#COPY build/etc/nginx/sites-enabled/default.conf /etc/nginx/templates/default.conf.template
31 +# Expose port 80
32 +EXPOSE 80
33
59 -# Copy built static files from the builder stage
60 -COPY --from=builder /app/dist /var/www/copilot
34 +# Health check
35 +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
36 + CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
37
38 CMD ["nginx", "-g", "daemon off;"]