-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (31 loc) · 1011 Bytes
/
Dockerfile
File metadata and controls
44 lines (31 loc) · 1011 Bytes
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
# Use official Node.js image as the base
FROM node:18-alpine AS build
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy the rest of the app
COPY . .
# Build the app
RUN BUILD_PATH=build npx craco build
# Production image, copy built assets from build stage
FROM nginx:alpine
# Install openssl for certificate generation
RUN apk add --no-cache openssl
# Create SSL directory
RUN mkdir -p /etc/nginx/ssl
# Generate self-signed certificate
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/nginx/ssl/nginx.key \
-out /etc/nginx/ssl/nginx.crt \
-subj "/C=US/ST=State/L=City/O=Organization/CN=yourdomain.com"
# Copy built assets
COPY --from=build /app/build /usr/share/nginx/html
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Expose ports for both HTTP and HTTPS
EXPOSE 80 443
# Start Nginx server
CMD ["nginx", "-g", "daemon off;"]