Add Node.js/Express API service to Docker Compose #1

Closed
opened 2026-07-07 21:37:37 -06:00 by jhodgkin · 0 comments
Owner

Goal

Add a lightweight backend alongside the existing nginx container so the booking form has somewhere to POST data.

Tasks

  • Create api/ directory with Express + SQLite app
  • api/server.js — base Express setup with health check at GET /api/health
  • api/db.js — SQLite init with bookings table schema
  • api/package.json — dependencies: express, better-sqlite3, cors, dotenv
  • api/Dockerfile — Node 20 Alpine image
  • Update docker-compose.yml to add api service on port 3001
  • Update nginx.conf to proxy /api/http://api:3001/

Bookings table schema

CREATE TABLE bookings (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  created_at TEXT DEFAULT (datetime("now")),
  client_name TEXT,
  client_email TEXT,
  client_phone TEXT,
  session_date TEXT,
  session_type TEXT,
  session_length TEXT,
  location TEXT,
  contract_signed_at TEXT,
  contract_pdf_path TEXT,
  payment_status TEXT DEFAULT "pending",
  status TEXT DEFAULT "pending"
);

Acceptance

  • docker compose up starts both nginx and api containers
  • GET /api/health returns {"ok":true}
  • POST /api/bookings stores a booking and returns the new id
## Goal Add a lightweight backend alongside the existing nginx container so the booking form has somewhere to POST data. ## Tasks - Create `api/` directory with Express + SQLite app - `api/server.js` — base Express setup with health check at `GET /api/health` - `api/db.js` — SQLite init with `bookings` table schema - `api/package.json` — dependencies: express, better-sqlite3, cors, dotenv - `api/Dockerfile` — Node 20 Alpine image - Update `docker-compose.yml` to add `api` service on port 3001 - Update `nginx.conf` to proxy `/api/` → `http://api:3001/` ## Bookings table schema ```sql CREATE TABLE bookings ( id INTEGER PRIMARY KEY AUTOINCREMENT, created_at TEXT DEFAULT (datetime("now")), client_name TEXT, client_email TEXT, client_phone TEXT, session_date TEXT, session_type TEXT, session_length TEXT, location TEXT, contract_signed_at TEXT, contract_pdf_path TEXT, payment_status TEXT DEFAULT "pending", status TEXT DEFAULT "pending" ); ``` ## Acceptance - `docker compose up` starts both nginx and api containers - `GET /api/health` returns `{"ok":true}` - `POST /api/bookings` stores a booking and returns the new id
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jhodgkin/lisilou-portfolio#1