-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (40 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
57 lines (40 loc) · 1.3 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
# Multi-stage build for Docker Mailserver GUI
# Stage 1: Build frontend
FROM node:18-alpine as frontend-builder
WORKDIR /app/frontend
# Copy frontend package.json and install dependencies
COPY frontend/package*.json ./
RUN npm ci
# Copy frontend code and build
COPY frontend/ ./
RUN npm run build
# Stage 2: Build backend
FROM node:18-alpine as backend-builder
WORKDIR /app/backend
# Copy backend package.json and install dependencies
COPY backend/package*.json ./
RUN npm ci --only=production
# Copy backend code
COPY backend/ ./
# Install Docker client inside the container for Docker API access
RUN apk add --no-cache docker-cli
# Stage 3: Final image with Nginx and Node.js
FROM node:18-alpine
# Install Nginx and Docker client
RUN apk add --no-cache nginx docker-cli
# Create app directories
WORKDIR /app
RUN mkdir -p /app/backend /app/frontend /run/nginx
# Copy backend from backend-builder
COPY --from=backend-builder /app/backend /app/backend
# Copy frontend build from frontend-builder
COPY --from=frontend-builder /app/frontend/dist /app/frontend
# Copy Nginx configuration
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
# Copy startup script
COPY docker/start.sh /app/start.sh
RUN chmod +x /app/start.sh
# Expose port for the application
EXPOSE 80
# Start Nginx and Node.js
CMD ["/app/start.sh"]