Add Docker Compose configuration

This commit is contained in:
gpt-engineer-app[bot]
2025-10-20 21:09:13 +00:00
parent 2972a83b2e
commit bdb1b75f36
5 changed files with 102 additions and 0 deletions

13
.dockerignore Normal file
View File

@@ -0,0 +1,13 @@
node_modules
dist
.git
.gitignore
*.md
.env
.env.local
.vscode
.idea
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

2
.env.example Normal file
View File

@@ -0,0 +1,2 @@
# Timezone
TZ=Europe/Copenhagen

34
Dockerfile Normal file
View File

@@ -0,0 +1,34 @@
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy source files
COPY . .
# Build the app
RUN npm run build
# Production stage
FROM nginx:alpine
# Copy built files to nginx
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080 || exit 1
CMD ["nginx", "-g", "daemon off;"]

24
docker-compose.yml Normal file
View File

@@ -0,0 +1,24 @@
version: '3.8'
services:
docker-webui:
build:
context: .
dockerfile: Dockerfile
container_name: docker-webui
ports:
- "8080:8080"
environment:
- TZ=${TZ:-Europe/Copenhagen}
volumes:
# Mount Docker socket for container management (read-only for safety)
- /var/run/docker.sock:/var/run/docker.sock:ro
# Mount proc for host metrics (read-only)
- /proc:/host/proc:ro
restart: unless-stopped
networks:
- docker-webui-network
networks:
docker-webui-network:
driver: bridge

29
nginx.conf Normal file
View File

@@ -0,0 +1,29 @@
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
# 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;
# SPA fallback - serve index.html for all routes
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}