first pass
This commit is contained in:
24
templates/static/nginx/.dockerignore.template
Normal file
24
templates/static/nginx/.dockerignore.template
Normal file
@@ -0,0 +1,24 @@
|
||||
.git
|
||||
.gitignore
|
||||
.env
|
||||
.env.local
|
||||
*.tar
|
||||
*.tar.gz
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Documentation (keep README.md for the site if needed)
|
||||
README.DOCKER.md
|
||||
docs
|
||||
|
||||
# Docker files
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
.dockerignore
|
||||
docker-deployment.json
|
||||
*.ps1
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
19
templates/static/nginx/Dockerfile.template
Normal file
19
templates/static/nginx/Dockerfile.template
Normal file
@@ -0,0 +1,19 @@
|
||||
FROM nginx:alpine
|
||||
|
||||
# Copy static files
|
||||
COPY . /usr/share/nginx/html
|
||||
|
||||
# Copy nginx configuration
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Remove Docker-related files from the served directory
|
||||
RUN rm -f /usr/share/nginx/html/Dockerfile \
|
||||
/usr/share/nginx/html/docker-compose.yml \
|
||||
/usr/share/nginx/html/.dockerignore \
|
||||
/usr/share/nginx/html/docker-deployment.json \
|
||||
/usr/share/nginx/html/*.ps1 \
|
||||
/usr/share/nginx/html/README.DOCKER.md 2>/dev/null || true
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
13
templates/static/nginx/docker-compose.yml.template
Normal file
13
templates/static/nginx/docker-compose.yml.template
Normal file
@@ -0,0 +1,13 @@
|
||||
services:
|
||||
{{PROJECT_NAME}}:
|
||||
build: .
|
||||
container_name: {{PROJECT_NAME}}
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HOST_PORT:-80}:80"
|
||||
{{#if HAS_VOLUMES}}
|
||||
volumes:
|
||||
{{#each VOLUMES}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
42
templates/static/nginx/nginx.conf.template
Normal file
42
templates/static/nginx/nginx.conf.template
Normal file
@@ -0,0 +1,42 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
# Handle SPA routing (fallback to index.html)
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# PHP handling (if PHP files exist)
|
||||
location ~ \.php$ {
|
||||
# Uncomment below if using PHP-FPM
|
||||
# fastcgi_pass php:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
|
||||
# For static sites without PHP, return 404
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot|pdf)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
}
|
||||
Reference in New Issue
Block a user