Skip to content

Commit 758b2db

Browse files
authored
Merge pull request #1385 from tabathad/docs/deployment-guide
docs: add deployment guide
2 parents cc5e5f3 + a13f35c commit 758b2db

2 files changed

Lines changed: 318 additions & 0 deletions

File tree

website/docs/deployment.mdx

Lines changed: 317 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,317 @@
1+
# Deployment Guide
2+
3+
This guide covers installing, configuring, and running GitProxy in both development and production environments.
4+
5+
For configuration details, see the [Configuration Overview](/docs/configuration/overview) and [Configuration Reference](/docs/configuration/reference).
6+
7+
---
8+
9+
## Prerequisites
10+
11+
### System Requirements
12+
13+
- **Node.js**: >= 20.18.2, >= 22.13.1, or >= 24.0.0
14+
- **Git**: Required for cloning and pack operations
15+
- **Operating System**: Linux, macOS, or Windows
16+
17+
### Database Options
18+
19+
GitProxy supports two database backends (configured in `proxy.config.json` under `"sink"`):
20+
21+
1. **NeDB (File-based)** — Default, suitable for development and single-server use
22+
- No external dependencies
23+
- Data stored in `./.data/db/` (hardcoded path, not configurable)
24+
- Sessions are in-memory only (lost on restart)
25+
26+
2. **MongoDB** — Recommended for production
27+
- Requires MongoDB 6.0+
28+
- Supports persistent sessions
29+
- Required for multi-instance deployments
30+
31+
### Optional Dependencies
32+
33+
- **[Gitleaks](https://github.com/gitleaks/gitleaks)** — For secret scanning. Must be installed separately; it is not bundled with GitProxy or the Docker image.
34+
- **Docker** — For containerized deployment
35+
36+
---
37+
38+
## Quick Start
39+
40+
### 1. Install GitProxy
41+
42+
```bash
43+
npm install -g @finos/git-proxy
44+
```
45+
46+
:::tip Quick testing with npx
47+
For quick local testing before committing to a full installation, you can use `npx` without installing globally:
48+
49+
```bash
50+
npx -- @finos/git-proxy --config ./proxy.config.json
51+
```
52+
53+
For persistent deployments, prefer `npm install -g` with version pinning (e.g., `npm install -g @finos/git-proxy@2.x.x`). See [Usage](/docs/quickstart/usage) for more details.
54+
:::
55+
56+
### 2. Create a Configuration File
57+
58+
Create `proxy.config.json` in your working directory:
59+
60+
```json
61+
{
62+
"authorisedList": [
63+
{
64+
"project": "my-org",
65+
"name": "my-repo",
66+
"url": "https://github.com/my-org/my-repo.git"
67+
}
68+
]
69+
}
70+
```
71+
72+
:::warning
73+
Repository URLs **must** include the `.git` suffix. Without it, you will get `fatal: info/refs not valid` errors.
74+
:::
75+
76+
### 3. Start GitProxy
77+
78+
```bash
79+
git-proxy --config ./proxy.config.json
80+
```
81+
82+
Expected output:
83+
```
84+
Listening on 8000
85+
Service Listening on 8080
86+
```
87+
88+
GitProxy runs two servers:
89+
90+
- **Proxy server** on port 8000 — intercepts git operations
91+
- **Service/UI server** on port 8080 — web dashboard and REST API
92+
93+
### 4. Configure Your Git Client
94+
95+
In your local repository, add GitProxy as a remote:
96+
97+
```bash
98+
cd /path/to/my-repo
99+
git remote add proxy http://localhost:8000/my-org/my-repo.git
100+
```
101+
102+
Or replace the existing origin:
103+
```bash
104+
git remote set-url origin http://localhost:8000/my-org/my-repo.git
105+
```
106+
107+
### 5. Test a Push
108+
109+
```bash
110+
git add .
111+
git commit -m "test: validate gitproxy integration"
112+
git push proxy main
113+
```
114+
115+
You should receive a message with a review URL:
116+
```
117+
remote: GitProxy has received your push
118+
remote: Shareable Link
119+
remote: http://localhost:8080/dashboard/push/000000__b12557
120+
```
121+
122+
### 6. Approve the Push
123+
124+
1. Navigate to http://localhost:8080 in your browser
125+
2. Log in with default credentials (**development only**):
126+
- Username: `admin`
127+
- Password: `admin`
128+
129+
See the [Authentication](https://github.com/finos/git-proxy/blob/main/docs/Architecture.md#authentication) section of the architecture guide for more details.
130+
3. Review the push and approve it
131+
4. Push again to forward to upstream:
132+
```bash
133+
git push proxy main
134+
```
135+
136+
---
137+
138+
## Docker Deployment
139+
140+
### Using the Published Image
141+
142+
A Docker image is published to [Docker Hub](https://hub.docker.com/r/finos/git-proxy):
143+
144+
```bash
145+
docker run -d \
146+
--name git-proxy \
147+
-p 8000:8000 \
148+
-p 8080:8080 \
149+
-v $(pwd)/proxy.config.json:/app/proxy.config.json:ro \
150+
finos/git-proxy:latest
151+
```
152+
153+
### Building from Source
154+
155+
```bash
156+
git clone https://github.com/finos/git-proxy.git
157+
cd git-proxy
158+
docker build -t git-proxy:local .
159+
```
160+
161+
The Dockerfile uses a multi-stage build with Node.js 20, installs `git` and `tini`, and runs as a non-root user (UID 1000). Ports 8000 (proxy) and 8080 (UI/API) are exposed.
162+
163+
View logs:
164+
```bash
165+
docker logs -f git-proxy
166+
```
167+
168+
### Runtime Environment Variables
169+
170+
The following environment variables can be set at container runtime:
171+
172+
| Variable | Default | Description |
173+
| ------------------------ | ------------ | -------------------------------------------------------- |
174+
| `GIT_PROXY_SERVER_PORT` | `8000` | Proxy server port |
175+
| `GIT_PROXY_UI_PORT` | `8080` | UI/API server port |
176+
| `ALLOWED_ORIGINS` | (empty) | CORS allowed origins (comma-separated, or `*` for all) |
177+
| `API_URL` | (empty) | API URL for the UI (leave empty for same-origin) |
178+
| `NODE_ENV` | `production` | Node environment |
179+
180+
Example with environment variables:
181+
```bash
182+
docker run -d \
183+
--name git-proxy \
184+
-p 8000:8000 \
185+
-p 8080:8080 \
186+
-e GIT_PROXY_UI_PORT=8080 \
187+
-e ALLOWED_ORIGINS="https://gitproxy.example.com" \
188+
-e NODE_ENV=production \
189+
-v $(pwd)/proxy.config.json:/app/proxy.config.json:ro \
190+
git-proxy:local
191+
```
192+
193+
### Persistent Data
194+
195+
When using the file-based database (NeDB), mount a volume for the data directory:
196+
197+
```bash
198+
docker run -d \
199+
--name git-proxy \
200+
-p 8000:8000 \
201+
-p 8080:8080 \
202+
-v $(pwd)/proxy.config.json:/app/proxy.config.json:ro \
203+
-v $(pwd)/data:/app/.data \
204+
git-proxy:local
205+
```
206+
207+
When using MongoDB, no additional data volumes are needed for GitProxy itself — data is stored in MongoDB.
208+
209+
---
210+
211+
## Git Client Configuration
212+
213+
### Setting GitProxy as a Remote
214+
215+
#### Option 1: Add as a new remote
216+
217+
```bash
218+
cd /path/to/repository
219+
git remote add proxy http://gitproxy.example.com:8000/org/repo.git
220+
git push proxy main
221+
```
222+
223+
#### Option 2: Replace origin
224+
225+
```bash
226+
git remote set-url origin http://gitproxy.example.com:8000/org/repo.git
227+
git push origin main
228+
```
229+
230+
### Credential Management
231+
232+
GitProxy prompts for credentials on each push. To cache credentials:
233+
234+
**macOS:**
235+
```bash
236+
git config --global credential.helper osxkeychain
237+
```
238+
239+
**Windows:**
240+
```bash
241+
git config --global credential.helper manager
242+
```
243+
244+
**Linux:**
245+
```bash
246+
git config --global credential.helper store
247+
```
248+
249+
**Required credentials for pushing through GitProxy to GitHub:**
250+
- GitHub username
251+
- Personal Access Token (PAT) with at minimum `public_repo` scope
252+
253+
### SSH Support
254+
255+
GitProxy currently supports HTTPS only. SSH protocol support is under active development.
256+
257+
---
258+
259+
## Production Considerations
260+
261+
### MongoDB for Production
262+
263+
Switch from the default file-based database to MongoDB for production use:
264+
265+
```json
266+
{
267+
"sink": [
268+
{
269+
"type": "mongo",
270+
"connectionString": "mongodb://user:password@mongodb-host:27017/gitproxy",
271+
"options": {
272+
"ssl": true,
273+
"tlsAllowInvalidCertificates": false
274+
},
275+
"enabled": true
276+
}
277+
]
278+
}
279+
```
280+
281+
**Recommendations:**
282+
- Use MongoDB 6.0 or later
283+
- Enable authentication and TLS/SSL
284+
- Configure replica sets for high availability
285+
- Schedule regular backups of audit data (`mongodump`)
286+
287+
### Health Checks
288+
289+
GitProxy provides health check endpoints on both servers:
290+
291+
- **`/healthcheck`** on the proxy port (8000) — returns `200 OK` with text body `"OK"`
292+
- **`/api/v1/healthcheck`** on the service port (8080) — returns `200 OK` with JSON body `{"message":"ok"}`
293+
294+
Use these for load balancer health probes, container orchestration liveness/readiness checks, or uptime monitoring.
295+
296+
### Monitoring
297+
298+
GitProxy does not currently ship with built-in metrics or structured logging. Recommended monitoring points:
299+
300+
- **Health endpoints** — poll `/healthcheck` and `/api/v1/healthcheck`
301+
- **Process health** — monitor Node.js process uptime and memory usage
302+
- **Database connectivity** — monitor MongoDB connection status
303+
- **Push activity** — query the pushes collection for approval/rejection rates
304+
305+
### Backup
306+
307+
**MongoDB:**
308+
```bash
309+
mongodump --uri="mongodb://localhost:27017/gitproxy" --out=/backup/$(date +%Y%m%d)
310+
```
311+
312+
**File-based (NeDB):**
313+
```bash
314+
tar -czf gitproxy-backup-$(date +%Y%m%d).tar.gz ./.data
315+
```
316+
317+
Always version-control your `proxy.config.json`.

website/sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = {
5050
collapsed: false,
5151
items: ['configuration/overview', 'configuration/reference', 'configuration/pre-receive'],
5252
},
53+
'deployment',
5354
{
5455
type: 'category',
5556
label: 'Development',

0 commit comments

Comments
 (0)