diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f1efc07 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +node_modules +dist +coverage +.vite +*.log +.env +.env.* +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d99f60e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:22-alpine AS build + +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +FROM nginx:1.27-alpine + +COPY docker/nginx.conf /etc/nginx/conf.d/default.conf +COPY --from=build /app/dist/ /usr/share/nginx/html/ + +EXPOSE 80 + +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1 diff --git a/README.md b/README.md index f7ddedd..b62c12b 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,41 @@ npm run build # production build → dist/ Built with Svelte 5, TypeScript, Vite and TipTap 3 (ProseMirror). +### Docker + +The production image builds the static application with Node.js and serves it +with Nginx. No application server or persistent volume is required; documents +remain in the browser. + +Build and run the image directly: + +```bash +docker build -t edentext . +docker run --rm -p 127.0.0.1:8080:80 edentext +``` + +Then open . + +Alternatively, use Docker Compose: + +```bash +docker compose up --build -d +``` + +The Compose service binds EdenText to by default. To use +a different host port, set `EDENTEXT_PORT`, for example: + +```bash +EDENTEXT_PORT=8081 docker compose up --build -d +``` + +Set `EDENTEXT_BIND_ADDRESS=0.0.0.0` to make the service reachable from other +machines. When finished, stop and remove it with: + +```bash +docker compose down +``` + ## Contributing Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Merging diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..c7ba3c2 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,8 @@ +services: + edentext: + build: + context: . + image: edentext:local + ports: + - "${EDENTEXT_BIND_ADDRESS:-127.0.0.1}:${EDENTEXT_PORT:-8080}:80" + restart: unless-stopped diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..749b270 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,18 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache"; + } + + location /assets/ { + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri =404; + } +}