-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.nginx
39 lines (27 loc) · 1.06 KB
/
Dockerfile.nginx
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
# Dockerfile.nginx
FROM nginx:1.23.3-alpine
# Create a non-privileged user for running Nginx
RUN adduser --disabled-password --gecos '' nginxuser
RUN mkdir -p /var/cache/nginx/client_temp \
&& mkdir -p /var/cache/nginx/proxy_temp \
&& mkdir -p /var/cache/nginx/fastcgi_temp \
&& chown -R nginxuser:nginxuser /var/cache/nginx
# Create the directory for PID file
RUN mkdir -p /var/run/nginx/
# Set appropriate permissions for the PID directory
RUN chown -R nginxuser:nginxuser /var/run/nginx/
# Create the directory for SSL certificates
RUN mkdir -p /etc/ssl/private/
# Create the directory for Nginx cache
RUN mkdir -p /var/cache/nginx/client_temp
RUN mkdir -p /var/cache/nginx/proxy_temp
RUN mkdir -p /var/cache/nginx/fastcgi_temp
RUN chown -R nginxuser:nginxuser /var/cache/nginx
# Copy SSL certificates into the Docker image
COPY certificate.crt /etc/ssl/private/certificate.crt
COPY private.key /etc/ssl/private/private.key
# Copy Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 443
USER nginxuser
CMD ["nginx", "-g", "daemon off;"]