Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .bass/issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Add Docker Compose dev configuration (docker-compose.dev.yml)

Provide a docker-compose.dev.yml file that spins up the server in a container with live-reload/volume mapping for local development. Include instructions in a README section.

Acceptance Criteria:
- docker-compose -f docker-compose.dev.yml up builds and starts the server
- Code changes are reflected without rebuilding the container (volume mount)
- SQLite file is persisted in a named volume or local directory so data survives container restarts

Test Cases:
- E2E/Manual: Start with docker-compose.dev.yml, create a todo, restart container, and verify todo persists
- E2E/Manual: Modify a source file and confirm the change is picked up by the running server

Please implement this fix.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:22-alpine

RUN apk add --no-cache python3 make g++

WORKDIR /app

COPY package*.json ./
RUN npm ci

COPY . .

EXPOSE 3000

CMD ["node", "server.js"]
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Todo App Server

A lightweight REST API server for managing personal todo items.

## Development with Docker Compose

### Quick Start

```bash
docker-compose -f docker-compose.dev.yml up --build
```

The server will be available at `http://localhost:3000`.

### Live Reload

The `docker-compose.dev.yml` mounts the project directory into the container. Any changes to source files are automatically picked up by `nodemon` without rebuilding the container.

### Data Persistence

Todos are stored in a SQLite database persisted in a named Docker volume (`sqlite-data`). Data survives container restarts.

### Manual Test Cases

**Persist data across restarts:**

```bash
# Start the server
docker-compose -f docker-compose.dev.yml up --build -d

# Create a todo
curl -X POST http://localhost:3000/todos \
-H "Content-Type: application/json" \
-d '{"title": "Buy milk"}'

# Restart the container
docker-compose -f docker-compose.dev.yml restart

# Verify the todo still exists
curl http://localhost:3000/todos
```

**Live reload on file changes:**

```bash
# Start the server
docker-compose -f docker-compose.dev.yml up --build

# In another terminal, modify a source file (e.g., add a log line to server.js)
# Watch the container logs — nodemon will restart the server automatically
```

### Stop

```bash
docker-compose -f docker-compose.dev.yml down
```

To remove the persisted database volume as well:

```bash
docker-compose -f docker-compose.dev.yml down -v
```
18 changes: 18 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
server:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
- sqlite-data:/app/data
environment:
- NODE_ENV=development
- DB_PATH=/app/data/todos.db
command: ["npx", "nodemon", "--legacy-watch", "server.js"]

volumes:
sqlite-data:
Loading