Skip to content
Open
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
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copy to .env to override without touching docker-compose.yml.
# Both are optional - unset values fall back to the defaults below.

# Host port for the frontend (container always listens on 80 internally)
CLIENT_PORT=5173

# Host port for the backend API (container always listens on 3000 internally)
SERVER_PORT=3001
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ web_modules/
.env.*
!.env.example

# local Docker Compose overrides
docker-compose.override.yml

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ To stop:
docker compose down
```

#### Overriding the Ports

If `5173` or `3001` are already in use on your machine, override them without editing `docker-compose.yml`:

```bash
cp .env.example .env
# then edit .env, or just export the values inline:
SERVER_PORT=4001 CLIENT_PORT=8080 docker compose up --build
```

`docker compose` automatically reads a `.env` file in the project root, so a committed `.env` is never required. Only the host-side port changes - the containers still talk to each other over the internal Docker network regardless of what you choose here.

### Docker Compose with SSH Key for Git Pull

If your repositories use SSH remotes (for example `git@github.com:...`), mount a private key into the server container:
Expand Down Expand Up @@ -339,11 +351,14 @@ cd server && npm run test:coverage

### Ports

- Backend: `3001` (configured in `server/src/index.ts`)
- Backend: `3001` (override with the `PORT` env var when running the server directly, e.g. `PORT=4001 npm run dev` in `server/`)
- Frontend: `5173` (Vite default)

Running via Docker Compose instead? See [Overriding the Ports](#overriding-the-ports) - use `SERVER_PORT`/`CLIENT_PORT` rather than `PORT`, since those control the host-side mapping while the containers keep talking to each other over the internal Docker network.

### Environment Variables

- Server port: `PORT` (default: `3001`)
- Frontend API base URL: `VITE_API_BASE_URL` (default: `http://localhost:3001`)
- Server DB path: `DB_FILE_PATH` (default: `<server cwd>/db.json`)
- Server upload directory: `UPLOAD_DIR` (default: `<server cwd>/uploads/`)
Expand Down
2 changes: 1 addition & 1 deletion client/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ server {
index index.html;

location /api/ {
proxy_pass http://server:3001/;
proxy_pass http://server:3000/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ services:
container_name: git-intelligence-server
environment:
NODE_ENV: production
PORT: 3000
DB_FILE_PATH: /data/db.json
UPLOAD_DIR: /data/uploads
volumes:
- server-data:/data
ports:
- '3001:3001'
- '${SERVER_PORT:-3001}:3000'

client:
build:
Expand All @@ -23,7 +24,7 @@ services:
depends_on:
- server
ports:
- '5173:80'
- '${CLIENT_PORT:-5173}:80'

volumes:
server-data:
3 changes: 2 additions & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ENV NODE_ENV=production
ENV DB_FILE_PATH=/data/db.json
ENV UPLOAD_DIR=/data/uploads

EXPOSE 3001
ENV PORT=3000
EXPOSE 3000

CMD ["node", "dist/index.js"]
2 changes: 1 addition & 1 deletion server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import settingsRouter from './routes/settings.js';
import { errorHandler } from './middleware/errorHandler.js';

const app = express();
const port = 3001;
const port = Number(process.env.PORT) || 3001;

// Middleware
app.use(cors());
Expand Down