[FEAT] Add docker files
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
||||
node_modules
|
||||
dist
|
||||
.git
|
||||
.gitignore
|
||||
.vscode
|
||||
*.md
|
||||
.DS_Store
|
||||
@@ -1,4 +1,4 @@
|
||||
http://spritesheetgenerator.online:1337 {
|
||||
:1337 {
|
||||
root * ./dist
|
||||
encode zstd gzip
|
||||
|
||||
@@ -19,7 +19,7 @@ http://spritesheetgenerator.online:1337 {
|
||||
}
|
||||
|
||||
log {
|
||||
output file /var/log/caddy/spritesheetgenerator.online.log
|
||||
output file /var/log/caddy/app.log
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
24
Caddyfile.docker
Normal file
24
Caddyfile.docker
Normal 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
32
Dockerfile
Normal 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
11
docker-compose.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- "${PORT:-1337}:1337"
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- caddy_logs:/var/log/caddy
|
||||
|
||||
volumes:
|
||||
caddy_logs:
|
||||
Reference in New Issue
Block a user