Add Docker support and new audio tracks
- Multi-stage Dockerfile: deps → dev (Vite hot reload) / build (typecheck + bundle) → runtime (nginx) - docker-compose.yml with a default `web` service (port 8080) and a `dev` profile for hot reload (port 5173); ports overridable via PIXELTATION_PORT / PIXELTATION_DEV_PORT - nginx config with gzip, immutable cache for fingerprinted /assets, and SPA fallback - .dockerignore to keep the build context lean - README: Docker Compose run instructions and a file reference table; note to rebuild the image after adding audio files - Add coastline.mp3 and fx-waves.mp3 tracks under public/audio/
This commit is contained in:
parent
42bf83c3ca
commit
15817f7c35
|
|
@ -0,0 +1,8 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
snapshots
|
||||||
|
.git
|
||||||
|
*.log
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
.dockerignore
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
|
# ---- deps: install node_modules once, shared by the dev and build stages ----
|
||||||
|
FROM node:22-alpine AS deps
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# ---- dev: Vite dev server with hot reload (used by the `dev` compose profile) ----
|
||||||
|
FROM deps AS dev
|
||||||
|
COPY . .
|
||||||
|
EXPOSE 5173
|
||||||
|
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "5173"]
|
||||||
|
|
||||||
|
# ---- build: typecheck and produce the static site in /app/dist ----
|
||||||
|
FROM deps AS build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ---- runtime: serve the static site with nginx ----
|
||||||
|
FROM nginx:1.29-alpine AS runtime
|
||||||
|
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 CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|
||||||
21
README.md
21
README.md
|
|
@ -4,12 +4,32 @@ Calm pixel art meditations for the browser. Pick a journey from the main menu, s
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
|
### With Node (local)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
npm run dev # http://localhost:5173
|
npm run dev # http://localhost:5173
|
||||||
npm run build # static site in dist/
|
npm run build # static site in dist/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### With Docker Compose
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker compose up --build -d # production build served by nginx → http://localhost:8080
|
||||||
|
docker compose --profile dev up --build dev # Vite dev server with hot reload → http://localhost:5173
|
||||||
|
docker compose down # stop
|
||||||
|
```
|
||||||
|
|
||||||
|
Change the host ports with `PIXELTATION_PORT` / `PIXELTATION_DEV_PORT`
|
||||||
|
(e.g. `PIXELTATION_PORT=3000 docker compose up -d`). The dev service bind-mounts the project,
|
||||||
|
so edits on the host reload in the browser; don't run it and `npm run dev` on the same port at once.
|
||||||
|
|
||||||
|
| File | Purpose |
|
||||||
|
|---|---|
|
||||||
|
| `Dockerfile` | Multi-stage: `deps` → `dev` (Vite) / `build` (typecheck + bundle) → `runtime` (nginx) |
|
||||||
|
| `docker-compose.yml` | `web` service (default) and `dev` service (`dev` profile) |
|
||||||
|
| `docker/nginx.conf` | Static serving, gzip, long-cache for fingerprinted `/assets` |
|
||||||
|
|
||||||
## Meditations
|
## Meditations
|
||||||
|
|
||||||
| id | Title | Length |
|
| id | Title | Length |
|
||||||
|
|
@ -24,6 +44,7 @@ that is scaled up crisply, so all art is generated in code.
|
||||||
|
|
||||||
Drop an audio file in `public/audio/` and set `music: 'audio/<file>.mp3'` on the meditation
|
Drop an audio file in `public/audio/` and set `music: 'audio/<file>.mp3'` on the meditation
|
||||||
(e.g. in `src/meditations/northern-cabin/index.ts`). It fades in at the start and out over the last 10 seconds.
|
(e.g. in `src/meditations/northern-cabin/index.ts`). It fades in at the start and out over the last 10 seconds.
|
||||||
|
With Docker, rebuild the `web` image (`docker compose up --build -d`) so the file is included.
|
||||||
|
|
||||||
## Dev tools
|
## Dev tools
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Production-style: docker compose up --build → http://localhost:8080
|
||||||
|
# Dev (hot reload): docker compose --profile dev up dev → http://localhost:5173
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: runtime
|
||||||
|
image: pixeltation:latest
|
||||||
|
ports:
|
||||||
|
- "${PIXELTATION_PORT:-8080}:80"
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
dev:
|
||||||
|
profiles: ["dev"]
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: dev
|
||||||
|
ports:
|
||||||
|
- "${PIXELTATION_DEV_PORT:-5173}:5173"
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
# Keep the container's own node_modules instead of the host's.
|
||||||
|
- /app/node_modules
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name _;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/css application/javascript application/json image/svg+xml;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
|
||||||
|
# Vite fingerprints everything under /assets, so it can be cached forever.
|
||||||
|
location /assets/ {
|
||||||
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Music files dropped into public/audio/.
|
||||||
|
location /audio/ {
|
||||||
|
add_header Cache-Control "public, max-age=86400";
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue