Skip to content

Commit 7872986

Browse files
committed
chore: Dockerize dev and test environments
1 parent 3adcb55 commit 7872986

File tree

6 files changed

+94
-26
lines changed

6 files changed

+94
-26
lines changed

Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# Base stage
4+
FROM node:20-slim AS base
5+
ENV NODE_ENV=production
6+
# Install Git (Required for git-cms)
7+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
8+
WORKDIR /app
9+
10+
# Deps stage
11+
FROM base AS deps
12+
COPY package.json package-lock.json* ./
13+
RUN npm ci --include=dev
14+
15+
# Development stage
16+
FROM base AS dev
17+
ENV NODE_ENV=development
18+
COPY --from=deps /app/node_modules ./node_modules
19+
COPY . .
20+
# Configure Git for Dev
21+
RUN git config --global user.email "dev@git-cms.local"
22+
RUN git config --global user.name "Git CMS Dev"
23+
RUN git config --global init.defaultBranch main
24+
CMD ["npm", "run", "serve"]
25+
26+
# Test stage
27+
FROM base AS test
28+
ENV NODE_ENV=test
29+
COPY --from=deps /app/node_modules ./node_modules
30+
COPY . .
31+
# Configure Git for Test
32+
RUN git config --global user.email "bot@git-cms.local"
33+
RUN git config --global user.name "Git CMS Bot"
34+
RUN git config --global init.defaultBranch main
35+
CMD ["npm", "run", "test:local"]

Dockerfile.test

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,44 @@ A serverless, database-free CMS built on Git plumbing.
66
77
**git-cms** treats your Git repository as a distributed, cryptographically verifiable database. Instead of files, it stores content as commit messages on "empty trees," creating a linear, append-only ledger for articles, comments, or any other structured data.
88

9+
## ⚠️ SAFETY WARNING
10+
11+
**If you clone this repo and want to run the tests, ALWAYS run them in Docker.**
12+
13+
The tests create, destroy, and manipulate Git repositories. While we try to use temporary directories, running low-level plumbing commands against your host filesystem is a risk you shouldn't take.
14+
15+
We provided a safe harness:
16+
```bash
17+
npm test
18+
# (This automatically runs ./test/run-docker.sh)
19+
```
20+
921
## Features
1022

1123
- **Database-Free:** No SQL, No NoSQL. Just Git objects (Merkle DAG).
1224
- **Fast-Forward Only:** Enforces strict linear history for provenance.
1325
- **Atomic Publishes:** "Publishing" is just a pointer update (CAS).
1426
- **Infinite History:** Every draft save is a commit. Scrub back to any point in time.
1527

28+
## Development
29+
30+
We use Docker Compose to ensure a consistent, safe environment.
31+
32+
### Start the Server (Dev Mode)
33+
```bash
34+
npm run dev
35+
# OR
36+
docker compose up app
37+
```
38+
The API and Admin UI will be available at `http://localhost:4637`.
39+
40+
### Run Tests
41+
```bash
42+
npm test
43+
# OR
44+
docker compose run --rm test
45+
```
46+
1647
## Installation
1748

1849
```bash

docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
app:
3+
build:
4+
context: .
5+
target: dev
6+
volumes:
7+
- .:/app
8+
- /app/node_modules
9+
ports:
10+
- "4637:4637"
11+
environment:
12+
- PORT=4637
13+
- GIT_CMS_ENV=dev
14+
command: npm run serve
15+
16+
test:
17+
build:
18+
context: .
19+
target: test
20+
volumes:
21+
- .:/app
22+
- /app/node_modules
23+
environment:
24+
- CI=true
25+
command: npm run test:local

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"scripts": {
1010
"serve": "node bin/git-cms.js serve",
11+
"dev": "docker compose up app",
1112
"test": "./test/run-docker.sh",
1213
"test:local": "vitest run",
1314
"test:e2e": "playwright test"

test/run-docker.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
# Build
5-
docker build -f Dockerfile.test -t git-cms-test .
6-
7-
# Run
8-
docker run --rm git-cms-test
4+
echo "🐳 Running tests in Docker..."
5+
docker compose run --rm test

0 commit comments

Comments
 (0)