From 102cf899f12019dd7dcd257bce1c28cbbe9a5ba7 Mon Sep 17 00:00:00 2001 From: Hiro Date: Sat, 28 Mar 2026 11:09:39 +0000 Subject: [PATCH] feat: add Docker configuration for deployment --- .dockerignore | 4 ++++ .env.development | 14 ++++++++++++++ .env.production | 14 ++++++++++++++ Dockerfile | 18 ++++++++++++++++++ docker-compose.yml | 23 +++++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 .dockerignore create mode 100644 .env.development create mode 100644 .env.production create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..40f5df4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +.env +data/ +*.log diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..d7a0921 --- /dev/null +++ b/.env.development @@ -0,0 +1,14 @@ +# SimpleNote Web - Development Environment + +# Server +PORT=3000 +NODE_ENV=development + +# Auth - generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" +ADMIN_TOKEN=dev-admin-token-change-in-production + +# Data +DATA_ROOT=./data + +# CORS (comma-separated origins or * for all) +CORS_ORIGIN=http://localhost:5173,http://localhost:3000 diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..229ad08 --- /dev/null +++ b/.env.production @@ -0,0 +1,14 @@ +# SimpleNote Web - Production Environment + +# Server +PORT=3000 +NODE_ENV=production + +# Auth +ADMIN_TOKEN=change-me-in-production + +# Data +DATA_ROOT=./data + +# CORS (comma-separated origins or * for all) +CORS_ORIGIN=* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7dcf7ca --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:18-alpine + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci --only=production + +COPY src/ ./src/ +COPY data/ ./data/ +COPY ui/ ./ui/ +COPY .env.example ./ + +EXPOSE 3000 + +ENV NODE_ENV=production +ENV PORT=3000 + +CMD ["node", "src/index.js"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7694588 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +services: + web: + build: . + container_name: simplenote-web + restart: unless-stopped + ports: + - "${SIMPLENOTE_PORT:-3000}:3000" + environment: + - NODE_ENV=production + - PORT=3000 + - ADMIN_TOKEN=${SIMPLENOTE_ADMIN_TOKEN} + - DATA_ROOT=/app/data + - CORS_ORIGIN=${SIMPLENOTE_CORS_ORIGIN:-*} + volumes: + - simplenote-data:/app/data + healthcheck: + test: ["CMD", "wget", "-qO-", "http://localhost:3000/health"] + interval: 30s + timeout: 10s + retries: 3 + +volumes: + simplenote-data: