Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
176 linesCodeBlameRaw
1# Self-hosted g1t, phase 1: the core forge on your own machine.
2#
3# docker compose -f deploy/self-host/docker-compose.yml up --build
4#
5# Then open http://localhost:8787. Mail (the confirmation link at sign-up)
6# lands in Mailpit at http://localhost:8025. The API is at
7# http://localhost:8789 and the MCP server at http://localhost:8789/mcp.
8#
9# What runs: the site and every core service in one workerd (g1t), git
10# repositories as bare repos on a volume (gitstore), the API in a second
11# workerd beside it, packages' files, backups and the clone pack cache in
12# RustFS (S3-compatible storage), and Mailpit for mail.
13# Agents, deployments, context search and billing are off. See
14# docs.g1t.sh/guides/self-hosting-architecture/.
15name: g1t
16
17services:
18 g1t:
19 build:
20 context: ../..
21 dockerfile: deploy/self-host/Dockerfile
22 ports:
23 - "${G1T_PORT:-8787}:8787"
24 - "${API_PORT:-8789}:8789"
25 environment:
26 # Where people reach this installation. Links in mail, clone URLs and
27 # the site's meta tags point here.
28 PUBLIC_URL: ${PUBLIC_URL:-http://localhost:8787}
29 # Where the API (REST, OAuth) is reached, and its OAuth issuer; empty
30 # means PUBLIC_URL's host on API_PORT. MCP_URL, empty, is API_URL/mcp.
31 API_URL: ${API_URL:-}
32 MCP_URL: ${MCP_URL:-}
33 # Where repository files and avatars are served: a host of its own
34 # that reaches this container, so they never share the site's
35 # cookies; empty serves them under PUBLIC_URL/-/usercontent.
36 USERCONTENT_URL: ${USERCONTENT_URL:-}
37 API_PORT: ${API_PORT:-8789}
38 GITSTORE_URL: http://gitstore:8080
39 GITSTORE_SECRET_FILE: /secrets/gitstore
40 MAIL_URL: ${MAIL_URL:-http://mailpit:8025}
41 MAIL_FROM: ${MAIL_FROM:-g1t <noreply@localhost>}
42 # Your own GitHub App, for "Continue with GitHub" and importing from
43 # GitHub. Leave these unset to have neither. See the self-hosting guide.
44 GITHUB_APP_ID: ${GITHUB_APP_ID:-}
45 GITHUB_APP_SLUG: ${GITHUB_APP_SLUG:-}
46 GITHUB_APP_CLIENT_ID: ${GITHUB_APP_CLIENT_ID:-}
47 GITHUB_APP_CLIENT_SECRET: ${GITHUB_APP_CLIENT_SECRET:-}
48 GITHUB_APP_PRIVATE_KEY: ${GITHUB_APP_PRIVATE_KEY:-}
49 GITHUB_APP_WEBHOOK_SECRET: ${GITHUB_APP_WEBHOOK_SECRET:-}
50 # Packages' files (container images and the rest), in RustFS below or
51 # any S3-compatible store. S3_PUBLIC_ENDPOINT, when clients can reach
52 # the store, sends large downloads there directly.
53 S3_ENDPOINT: ${S3_ENDPOINT:-http://rustfs:9000}
54 S3_BUCKET: ${S3_BUCKET:-g1t-packages}
55 S3_REGION: ${S3_REGION:-us-east-1}
56 S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-g1t}
57 S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-g1t-packages-secret}
58 S3_PUBLIC_ENDPOINT: ${S3_PUBLIC_ENDPOINT:-}
59 # Nightly backups' bundles and manifests, in a bucket of their own on
60 # the same store (docs.g1t.sh/guides/self-hosting-architecture/#storage).
61 BACKUP_S3_BUCKET: ${BACKUP_S3_BUCKET:-g1t-backups}
62 # Packs kept for fresh clones, so the next clone of the same commit
63 # does not rebuild one; storage-setup expires them after 7 days.
64 PACK_S3_BUCKET: ${PACK_S3_BUCKET:-g1t-git-packs}
65 # Images and files people put in Docs pages.
66 DOCS_S3_BUCKET: ${DOCS_S3_BUCKET:-g1t-docs-files}
67 volumes:
68 - g1t-data:/data
69 - g1t-secrets:/secrets:ro
70 depends_on:
71 gitstore:
72 condition: service_healthy
73 mailpit:
74 condition: service_started
75 storage-setup:
76 condition: service_completed_successfully
77 restart: unless-stopped
78
79 # The status page, in a process of its own so it stays up when the site
80 # does not: http://localhost:8788. It checks the site every minute.
81 status:
82 build:
83 context: ../..
84 dockerfile: deploy/self-host/Dockerfile
85 command: ["bash", "deploy/self-host/status.sh"]
86 ports:
87 - "${STATUS_PORT:-8788}:8788"
88 environment:
89 PUBLIC_URL: ${PUBLIC_URL:-http://localhost:8787}
90 # How the status page reaches the site, from inside Compose.
91 STATUS_CHECK_URL: http://g1t:8787
92 # A public repository, `workspace/repo`, whose branches it lists as a
93 # clone would. Empty: git is not checked.
94 STATUS_PROBE_REPO: ${STATUS_PROBE_REPO:-}
95 volumes:
96 - g1t-status:/data
97 restart: unless-stopped
98
99 gitstore:
100 build:
101 context: ./gitstore
102 environment:
103 GITSTORE_URL: http://gitstore:8080
104 GITSTORE_SECRET_FILE: /secrets/gitstore
105 volumes:
106 - g1t-git:/data/git
107 - g1t-secrets:/secrets
108 # Not published: only the g1t container reaches it.
109 restart: unless-stopped
110
111 # Packages' files, backups and clone packs, in RustFS (S3-compatible).
112 # Not published: only the g1t container reaches it, unless you publish
113 # 9000 and set S3_PUBLIC_ENDPOINT. Any S3-compatible store works in its
114 # place (S3_ENDPOINT).
115 rustfs:
116 image: ${RUSTFS_IMAGE:-rustfs/rustfs:1.0.1}
117 environment:
118 RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY_ID:-g1t}
119 RUSTFS_SECRET_KEY: ${S3_SECRET_ACCESS_KEY:-g1t-packages-secret}
120 RUSTFS_CONSOLE_ENABLE: "false"
121 volumes:
122 - g1t-objects:/data
123 healthcheck:
124 test: ["CMD", "curl", "-fsS", "-o", "/dev/null", "http://localhost:9000/health/ready"]
125 interval: 5s
126 retries: 20
127 restart: unless-stopped
128
129 # Makes the buckets once, then exits: packages' files, backups, clone
130 # packs and Docs pages' files, with a lifecycle rule on the packs' bucket that deletes
131 # packs 7 days old and uploads left unfinished after a day.
132 storage-setup:
133 image: ${AWS_CLI_IMAGE:-amazon/aws-cli:2.37.10}
134 depends_on:
135 rustfs:
136 condition: service_healthy
137 entrypoint:
138 - sh
139 - -c
140 - >-
141 set -e;
142 for bucket in "$$S3_BUCKET" "$$BACKUP_S3_BUCKET" "$$PACK_S3_BUCKET" "$$DOCS_S3_BUCKET"; do
143 aws s3api head-bucket --bucket "$$bucket" >/dev/null 2>&1 || aws s3api create-bucket --bucket "$$bucket" >/dev/null;
144 done;
145 aws s3api put-bucket-lifecycle-configuration --bucket "$$PACK_S3_BUCKET" --lifecycle-configuration
146 '{"Rules":[{"ID":"expire-packs","Status":"Enabled","Filter":{"Prefix":"packs/"},"Expiration":{"Days":7}},{"ID":"abort-unfinished-uploads","Status":"Enabled","Filter":{"Prefix":""},"AbortIncompleteMultipartUpload":{"DaysAfterInitiation":1}}]}';
147 echo "buckets ready"
148 environment:
149 AWS_ENDPOINT_URL: http://rustfs:9000
150 AWS_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-g1t}
151 AWS_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-g1t-packages-secret}
152 AWS_DEFAULT_REGION: ${S3_REGION:-us-east-1}
153 S3_BUCKET: ${S3_BUCKET:-g1t-packages}
154 BACKUP_S3_BUCKET: ${BACKUP_S3_BUCKET:-g1t-backups}
155 PACK_S3_BUCKET: ${PACK_S3_BUCKET:-g1t-git-packs}
156 DOCS_S3_BUCKET: ${DOCS_S3_BUCKET:-g1t-docs-files}
157
158 mailpit:
159 image: axllent/mailpit:latest
160 ports:
161 - "${MAILPIT_PORT:-8025}:8025"
162 # To deliver for real, relay through your SMTP server:
163 # environment:
164 # MP_SMTP_RELAY_HOST: smtp.example.com
165 # MP_SMTP_RELAY_PORT: "587"
166 # MP_SMTP_RELAY_USERNAME: ...
167 # MP_SMTP_RELAY_PASSWORD: ...
168 # MP_SMTP_RELAY_ALL: "true"
169 restart: unless-stopped
170
171volumes:
172 g1t-data:
173 g1t-objects:
174 g1t-status:
175 g1t-git:
176 g1t-secrets: