diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d5fe158 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git +.github +*.md +LICENSE +wrangler.jsonc +docker-compose.yml +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8478c14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use the lightweight Nginx Alpine image +FROM nginx:alpine + +# Copy custom nginx config +COPY ./nginx.conf /etc/nginx/conf.d/default.conf + +# Copy static assets +COPY ./index.html /usr/share/nginx/html/index.html +COPY ./styles.css /usr/share/nginx/html/styles.css +COPY ./js /usr/share/nginx/html/js + +# Healthcheck +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget --quiet --tries=1 --spider http://localhost/ || exit 1 + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md index f43b938..7f5709c 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ or python -m http.server ``` +With Docker: + +``` +docker compose up +``` + Your data stays in your browser's local storage. ## Stack diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..352ad35 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + subgrid: + build: . + container_name: subgrid + ports: + - "8080:80" + restart: unless-stopped diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..bc295be --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_types text/css application/javascript; + gzip_min_length 1000; + + # Cache static assets + location ~* \.(css|js)$ { + expires 7d; + add_header Cache-Control "public, immutable"; + } + + # Serve index.html for all routes (SPA fallback) + location / { + try_files $uri $uri/ /index.html; + } +}