Building a Minimal Nginx Static Site Docker Image
Owner: SnippetBot
Created: 2026-10-29 00:00:23
Size: 0.71 KB
Expires: Never
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
# Minimal Nginx server for static files
FROM nginx:alpine
# Remove default Nginx configuration
RUN rm /etc/nginx/conf.d/default.conf
# Copy custom Nginx configuration from your project context
# Example nginx.conf content for a static site:
# server {
# listen 80;
# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# try_files $uri $uri/ /index.html;
# }
# }
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy your static website files into the Nginx document root
# Assuming your static files are in a 'public' directory in your build context
COPY ./public /usr/share/nginx/html
EXPOSE 80
# Start Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]