@@ -10,7 +10,7 @@ Images are available for both
1010and
1111[ PostgreSQL] ( https://github.com/mozilla-services/syncstorage-rs/pkgs/container/syncstorage-rs%2Fsyncstorage-rs-postgres )
1212as the database. Differences in configuration or deployment steps will be
13- noted.
13+ noted.
1414
1515Tagged release builds are available on ghcr.io. To pin to a specific version,
1616set ` SYNCSERVER_VERSION ` to the desired release tag (e.g., ` SYNCSERVER_VERSION=v1.45.0 ` )
@@ -142,6 +142,145 @@ Next, start the service with `docker compose`:
142142docker compose -f docker-compose.one-shot.yaml up -d
143143` ` `
144144
145+ # # Docker Compose, One-Shot with MySQL
146+
147+ This recipe brings up everything needed for a working MySQL-backed server in a
148+ single command : a MySQL database for Syncstorage and one for Tokenserver, plus
149+ the server itself. Syncstorage applies its schema migrations automatically at
150+ startup, `SYNC_TOKENSERVER__RUN_MIGRATIONS` applies the Tokenserver schema, and
151+ ` SYNC_TOKENSERVER__INIT_NODE_URL` bootstraps the `sync-1.5` service and storage
152+ node records — so the stack is ready to serve with no manual database setup.
153+
154+ # ## Option A: build from source (works from a checkout)
155+
156+ Run this from a clone of the repository; the build `context` is the repo root,
157+ so the MySQL build of the server is compiled locally and the recipe does not
158+ depend on any published image. Save the yaml below into a file, e.g.
159+ ` docker-compose.one-shot.yaml` .
160+
161+ ` ` ` yaml
162+ services:
163+ syncserver:
164+ build:
165+ context: .
166+ args:
167+ SYNCSTORAGE_DATABASE_BACKEND: mysql
168+ TOKENSERVER_DATABASE_BACKEND: mysql
169+ container_name: syncserver
170+ ports:
171+ - "8000:8000"
172+ environment:
173+ SYNC_HOST: "0.0.0.0"
174+ SYNC_PORT: "8000"
175+ SYNC_MASTER_SECRET: "${SYNC_MASTER_SECRET:-changeme_secret_key}"
176+ SYNC_SYNCSTORAGE__DATABASE_URL: "mysql://sync:sync@sync-db:3306/syncstorage"
177+ SYNC_TOKENSERVER__DATABASE_URL: "mysql://sync:sync@tokenserver-db:3306/tokenserver"
178+ SYNC_TOKENSERVER__ENABLED: "true"
179+ SYNC_TOKENSERVER__NODE_TYPE: "mysql"
180+ SYNC_TOKENSERVER__RUN_MIGRATIONS: "true"
181+ SYNC_TOKENSERVER__FXA_EMAIL_DOMAIN: "api.accounts.firefox.com"
182+ SYNC_TOKENSERVER__FXA_OAUTH_SERVER_URL: "https://oauth.accounts.firefox.com"
183+ SYNC_HUMAN_LOGS: "${SYNC_HUMAN_LOGS:-false}"
184+ RUST_LOG: "${RUST_LOG:-info}"
185+ SYNC_TOKENSERVER__INIT_NODE_URL: "${SYNC_TOKENSERVER__INIT_NODE_URL:-http://localhost:${SYNC_PORT:-8000}}"
186+ depends_on:
187+ sync-db:
188+ condition: service_healthy
189+ tokenserver-db:
190+ condition: service_healthy
191+ restart: unless-stopped
192+ healthcheck:
193+ test: ["CMD", "curl", "-f", "http://localhost:8000/__heartbeat__"]
194+ interval: 30s
195+ timeout: 10s
196+ retries: 3
197+ start_period: 60s
198+
199+ sync-db:
200+ image: docker.io/library/mysql:8.0
201+ container_name: syncserver-sync-db
202+ command: --explicit_defaults_for_timestamp
203+ environment:
204+ MYSQL_RANDOM_ROOT_PASSWORD: "yes"
205+ MYSQL_DATABASE: syncstorage
206+ MYSQL_USER: sync
207+ MYSQL_PASSWORD: sync
208+ volumes:
209+ - sync_db_data:/var/lib/mysql
210+ healthcheck:
211+ test: ["CMD-SHELL", "mysqladmin -h 127.0.0.1 -usync -psync ping"]
212+ interval: 10s
213+ timeout: 5s
214+ retries: 5
215+ start_period: 30s
216+ restart: unless-stopped
217+
218+ tokenserver-db:
219+ image: docker.io/library/mysql:8.0
220+ container_name: syncserver-tokenserver-db
221+ command: --explicit_defaults_for_timestamp
222+ environment:
223+ MYSQL_RANDOM_ROOT_PASSWORD: "yes"
224+ MYSQL_DATABASE: tokenserver
225+ MYSQL_USER: sync
226+ MYSQL_PASSWORD: sync
227+ volumes:
228+ - tokenserver_db_data:/var/lib/mysql
229+ healthcheck:
230+ test: ["CMD-SHELL", "mysqladmin -h 127.0.0.1 -usync -psync ping"]
231+ interval: 10s
232+ timeout: 5s
233+ retries: 5
234+ start_period: 30s
235+ restart: unless-stopped
236+
237+ volumes:
238+ sync_db_data:
239+ driver: local
240+ tokenserver_db_data:
241+ driver: local
242+ ` ` `
243+
244+ Next, build and start the service with `docker compose` :
245+
246+ ` ` ` sh
247+ docker compose -f docker-compose.one-shot.yaml up -d --build
248+ ` ` `
249+
250+ Once the `syncserver` container reports healthy, confirm it is serving :
251+
252+ ` ` ` sh
253+ curl http://localhost:8000/__heartbeat__
254+ ` ` `
255+
256+ # ## Option B: use a published image
257+
258+ Mozilla also publishes prebuilt images on ghcr.io. Note that these are
259+ currently tagged by commit SHA — there is **no `latest` or semver tag** — so
260+ you must pin `SYNCSERVER_VERSION` to a tag listed on the
261+ [`syncstorage-rs-mysql` packages page](https://github.com/mozilla-services/syncstorage-rs/pkgs/container/syncstorage-rs%2Fsyncstorage-rs-mysql).
262+ To use a published image, replace the `syncserver` service's `build:` block with
263+ an `image:` reference; the `sync-db`, `tokenserver-db`, and `volumes` sections
264+ are unchanged :
265+
266+ ` ` ` yaml
267+ services:
268+ syncserver:
269+ image: ghcr.io/mozilla-services/syncstorage-rs/syncstorage-rs-mysql:${SYNCSERVER_VERSION:?set SYNCSERVER_VERSION to a published tag}
270+ platform: linux/amd64
271+ container_name: syncserver
272+ # ...the remaining syncserver settings are identical to Option A
273+ ` ` `
274+
275+ Then start it with the tag pinned (published images are `linux/amd64`) :
276+
277+ ` ` ` sh
278+ SYNCSERVER_VERSION=<published-tag> docker compose -f docker-compose.one-shot.yaml up -d
279+ ` ` `
280+
281+ > Set `SYNC_MASTER_SECRET` to your own value for anything beyond local
282+ > experimentation; the default above is a placeholder.
283+
145284# # Configuring Firefox (Desktop)
146285
147286Firefox itself needs to be configured to use the self-hosted Sync server.
0 commit comments