[FEAT] Add docker files

This commit is contained in:
2026-01-09 03:24:35 +01:00
parent cdb86452c3
commit 1c2325170a
5 changed files with 76 additions and 2 deletions

7
.dockerignore Normal file
View File

@@ -0,0 +1,7 @@
node_modules
dist
.git
.gitignore
.vscode
*.md
.DS_Store

View File

@@ -1,4 +1,4 @@
http://spritesheetgenerator.online:1337 { :1337 {
root * ./dist root * ./dist
encode zstd gzip encode zstd gzip
@@ -19,7 +19,7 @@ http://spritesheetgenerator.online:1337 {
} }
log { log {
output file /var/log/caddy/spritesheetgenerator.online.log output file /var/log/caddy/app.log
} }
} }

24
Caddyfile.docker Normal file
View File

@@ -0,0 +1,24 @@
:1337 {
root * /srv/dist
encode zstd gzip
# Aggressive caching for static assets
@static path *.js *.css *.png *.jpg *.jpeg *.gif *.webp *.svg *.woff *.woff2 *.ico
header @static Cache-Control "public, max-age=31536000, immutable"
# Short cache for HTML (for SPA updates)
@html path *.html /
header @html Cache-Control "no-cache, must-revalidate"
# Default cache for everything else
header ?Cache-Control "max-age=1800"
try_files {path} /index.html
file_server {
precompressed zstd gzip
}
log {
output stdout
}
}

32
Dockerfile Normal file
View File

@@ -0,0 +1,32 @@
# Build stage
FROM node:22-alpine AS builder
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies
RUN npm ci
# Copy source files
COPY . .
# Build the app
RUN npm run build
# Production stage
FROM caddy:2-alpine
# Create log directory
RUN mkdir -p /var/log/caddy
# Copy built files
COPY --from=builder /app/dist /srv/dist
# Copy Caddy configuration
COPY Caddyfile.docker /etc/caddy/Caddyfile
EXPOSE 1337
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]

11
docker-compose.yml Normal file
View File

@@ -0,0 +1,11 @@
services:
app:
build: .
ports:
- "${PORT:-1337}:1337"
restart: unless-stopped
volumes:
- caddy_logs:/var/log/caddy
volumes:
caddy_logs: