otaship 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ .git/
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .omc/
6
+ data/
7
+ dist/
8
+ build/
9
+ **/__pycache__/
10
+ tests/
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
18
+ steps:
19
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
20
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+ - run: pip install -e '.[dev]'
24
+ - run: ruff check .
25
+ - run: pytest --cov --cov-report=term-missing --cov-fail-under=85
@@ -0,0 +1,65 @@
1
+ name: Release
2
+
3
+ # Publishes to PyPI with Trusted Publishing (OIDC): no API token is stored anywhere.
4
+ # Trigger: publish a GitHub Release whose tag is v<version> matching pyproject.toml.
5
+
6
+ on:
7
+ release:
8
+ types: [published]
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: ["3.10", "3.13"]
19
+ steps:
20
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
21
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ - run: pip install -e '.[dev]'
25
+ - run: ruff check .
26
+ - run: pytest --cov --cov-fail-under=85
27
+
28
+ build:
29
+ needs: test
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
33
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
34
+ with:
35
+ python-version: "3.12"
36
+ - name: Check tag matches package version
37
+ run: |
38
+ v=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
39
+ test "v$v" = "${GITHUB_REF_NAME}" || { echo "tag ${GITHUB_REF_NAME} != v$v"; exit 1; }
40
+ - run: pip install build
41
+ - run: python -m build
42
+ - name: Smoke-test the built wheel outside the source tree
43
+ run: |
44
+ python -m venv /tmp/smoke
45
+ /tmp/smoke/bin/pip install dist/*.whl
46
+ cd /tmp && /tmp/smoke/bin/otaship --help && /tmp/smoke/bin/python -c "import otaship.app"
47
+ - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+
52
+ publish:
53
+ needs: build
54
+ runs-on: ubuntu-latest
55
+ environment:
56
+ name: pypi
57
+ url: https://pypi.org/p/otaship
58
+ permissions:
59
+ id-token: write
60
+ steps:
61
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
62
+ with:
63
+ name: dist
64
+ path: dist/
65
+ - uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
@@ -0,0 +1,16 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ .coverage
7
+ coverage.xml
8
+ htmlcov/
9
+ dist/
10
+ build/
11
+ *.egg-info/
12
+ data/
13
+ keys/
14
+ *.pem
15
+ .otaship.json
16
+ .omc/
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses semantic versioning.
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.1.0] - 2026-12-06
9
+
10
+ First public release.
11
+
12
+ ### Fixed (pre-release review)
13
+ - Assets are served with `Content-Security-Policy: sandbox` so uploaded HTML/SVG cannot script the dashboard origin.
14
+ - Unauthenticated bodies (`/health`, dashboard forms) are size-limited while streaming.
15
+ - Re-activating an update after `rollBackToEmbedded` re-publishes it newer than the directive.
16
+ - Protocol 0 manifests are signed (`expo-signature` response header).
17
+ - Unreadable metadata fails the request instead of being treated as empty state.
18
+ - Auto-rollback re-checks the rollout opt-in under the channel lock.
19
+ - Response format follows the `Accept` header with RFC 9110 specificity (multipart or JSON, else 406).
20
+ - `createdAt` ordering is compared at the millisecond precision sent on the wire.
21
+
22
+ ## [0.1.0]
23
+
24
+ ### Added
25
+ - `expo-updates` protocol 0 and 1: manifests, multipart responses, `noUpdateAvailable` and
26
+ `rollBackToEmbedded` directives, RSA-SHA256 code signing.
27
+ - Content-addressed blob store with verified uploads, atomic metadata writes and per-channel locks.
28
+ - Admin API (bearer token): blob upload, register, activate, rollback (previous / embedded),
29
+ staged rollouts (stage / promote / abort), channel listing and history.
30
+ - `otaship` CLI: `init` (with `--signing`), `publish`, `rollback`, `rollout`, `status`, `serve`.
31
+ - Auto-rollback guard for staged rollouts based on launch confirmations, plus `POST /health`.
32
+ - Server-rendered admin dashboard with CSRF-protected actions.
33
+ - HMAC-signed webhooks.
@@ -0,0 +1,27 @@
1
+ # Contributing
2
+
3
+ Thanks for helping! Bug reports, docs fixes and pull requests are welcome.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ python3 -m venv .venv
9
+ .venv/bin/pip install -e '.[dev]'
10
+ .venv/bin/pytest --cov # tests + coverage
11
+ .venv/bin/ruff check . # lint
12
+ ```
13
+
14
+ ## Guidelines
15
+
16
+ - Keep it small. The server should stay a single dependency-light package.
17
+ - Every behaviour change comes with a test. Protocol changes should cite the
18
+ [expo-updates spec](https://docs.expo.dev/technical-specs/expo-updates-1/) section they follow.
19
+ - Anything that becomes part of a file path must go through `validation.py`.
20
+ - State changes to a channel happen inside `storage.lock(...)` and re-check the expected state there.
21
+ - Do not log raw `eas-client-id` values or tokens.
22
+ - Use conventional commit messages (`feat:`, `fix:`, `docs:`, `test:`, `chore:`).
23
+
24
+ ## Reporting security issues
25
+
26
+ Please do not open a public issue for security problems; contact the maintainers privately
27
+ (see [SECURITY.md](SECURITY.md)) with a description and reproduction steps.
@@ -0,0 +1,15 @@
1
+ FROM python:3.12-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 OTASHIP_DATA_DIR=/data
4
+
5
+ RUN useradd --system --uid 10001 --home /data otaship && mkdir /data && chown otaship /data
6
+ WORKDIR /app
7
+ COPY pyproject.toml README.md LICENSE ./
8
+ COPY src ./src
9
+ RUN pip install --no-cache-dir .
10
+
11
+ USER otaship
12
+ VOLUME ["/data"]
13
+ EXPOSE 8000
14
+ HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz')"
15
+ CMD ["otaship", "serve", "--host", "0.0.0.0", "--port", "8000", "--forwarded-allow-ips", "*"]
otaship-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 otaship contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
otaship-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,374 @@
1
+ Metadata-Version: 2.5
2
+ Name: otaship
3
+ Version: 0.1.0
4
+ Summary: Self-hosted update server for Expo apps (expo-updates protocol) with staged rollouts, auto-rollback and a built-in dashboard.
5
+ Project-URL: Homepage, https://github.com/otaship-dev/otaship
6
+ Project-URL: Repository, https://github.com/otaship-dev/otaship
7
+ Project-URL: Issues, https://github.com/otaship-dev/otaship/issues
8
+ Project-URL: Changelog, https://github.com/otaship-dev/otaship/blob/main/CHANGELOG.md
9
+ Author: otaship contributors
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: code-push,expo,expo-updates,ota,react-native,self-hosted
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: FastAPI
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Build Tools
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: cryptography>=42
24
+ Requires-Dist: fastapi>=0.110
25
+ Requires-Dist: httpx>=0.27
26
+ Requires-Dist: uvicorn>=0.27
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
29
+ Requires-Dist: pytest>=8; extra == 'dev'
30
+ Requires-Dist: ruff>=0.5; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # otaship
34
+
35
+ [![CI](https://github.com/otaship-dev/otaship/actions/workflows/ci.yml/badge.svg)](https://github.com/otaship-dev/otaship/actions/workflows/ci.yml)
36
+ [![PyPI](https://img.shields.io/pypi/v/otaship.svg)](https://pypi.org/project/otaship/)
37
+ [![Python](https://img.shields.io/pypi/pyversions/otaship.svg)](https://pypi.org/project/otaship/)
38
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
39
+
40
+ A small, self-hosted update server for Expo / React Native apps that speaks the
41
+ [`expo-updates` protocol](https://docs.expo.dev/technical-specs/expo-updates-1/).
42
+ Publish over-the-air updates from your own machine to your own server.
43
+
44
+ - **Unlimited MAU, zero per-user fees.** Cost is your server and bandwidth, nothing per device.
45
+ - **Your storage, your CDN.** Assets are immutable, content-addressed files; serve them from
46
+ nginx, a CDN, or anything that can serve static files.
47
+ - **No vendor lock-in.** Plain files on disk, a documented JSON layout, one Python package (MIT).
48
+ - **Auto-rollback.** Staged rollouts can abort themselves when devices fail to launch the update.
49
+ - **Built-in dashboard.** One server-rendered page: active updates, rollouts, adoption, health,
50
+ history, and promote / abort / rollback buttons. No JavaScript framework, no external CDN.
51
+ - **Signed webhooks** for publish, promote, abort, rollback and auto-rollback.
52
+ - **Code signing** compatible with `expo-updates` (`rsa-v1_5-sha256`).
53
+
54
+ It works with stock `expo-updates`: no native changes, no custom client library.
55
+
56
+ ## Used in production
57
+
58
+ otaship is extracted from the update server behind [Yaqeen](https://getyaqeen.com), a Quran
59
+ and prayer app for Android and iOS. That server has delivered over-the-air updates to tens of
60
+ thousands of devices on two channels since September 2026. otaship is a clean rewrite of it as a
61
+ general-purpose package; the protocol handling, storage layout and rollout logic come from that
62
+ production code.
63
+
64
+ Running otaship in production? Open a pull request to add your app here.
65
+
66
+ ## Contents
67
+
68
+ - [Used in production](#used-in-production)
69
+ - [Quickstart](#quickstart)
70
+ - [App configuration](#app-configuration)
71
+ - [Publishing](#publishing)
72
+ - [Staged rollouts](#staged-rollouts)
73
+ - [Auto-rollback](#auto-rollback)
74
+ - [Rollback](#rollback)
75
+ - [Dashboard](#dashboard)
76
+ - [Webhooks](#webhooks)
77
+ - [Code signing](#code-signing)
78
+ - [Deployment, nginx and CDN caching](#deployment-nginx-and-cdn-caching)
79
+ - [Configuration reference](#configuration-reference)
80
+ - [Comparison with EAS Update](#comparison-with-eas-update)
81
+ - [Limitations](#limitations)
82
+
83
+ ## Quickstart
84
+
85
+ ```bash
86
+ pip install otaship
87
+
88
+ # on the server
89
+ export OTASHIP_ADMIN_TOKEN="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
90
+ export OTASHIP_PUBLIC_URL="https://updates.example.com"
91
+ export OTASHIP_DATA_DIR=/var/lib/otaship
92
+ otaship serve --host 127.0.0.1 --port 8000 # put it behind TLS (see below)
93
+
94
+ # in your Expo project
95
+ otaship init --server https://updates.example.com
96
+ export OTASHIP_ADMIN_TOKEN=... # same token as the server
97
+ otaship publish -m "Fix checkout button"
98
+ ```
99
+
100
+ Or with Docker:
101
+
102
+ ```bash
103
+ docker build -t otaship .
104
+ docker run -p 8000:8000 -v otaship-data:/data \
105
+ -e OTASHIP_ADMIN_TOKEN=... -e OTASHIP_PUBLIC_URL=https://updates.example.com otaship
106
+ ```
107
+
108
+ ## App configuration
109
+
110
+ In `app.json` (or `app.config.js`), point `expo-updates` at the server and choose a channel
111
+ with a request header. `otaship init` prints this snippet for you.
112
+
113
+ ```json
114
+ {
115
+ "expo": {
116
+ "runtimeVersion": { "policy": "appVersion" },
117
+ "updates": {
118
+ "url": "https://updates.example.com/manifest",
119
+ "requestHeaders": { "expo-channel-name": "production" }
120
+ }
121
+ }
122
+ }
123
+ ```
124
+
125
+ - **Channel**: the `expo-channel-name` header. Builds without it use `OTASHIP_DEFAULT_CHANNEL`
126
+ (`production`). Use a different value per build profile (for example `staging`).
127
+ - **Runtime version**: the server only serves updates published for the runtime version the build
128
+ reports. `otaship publish` reads a string `runtimeVersion` from your expo config; with a policy
129
+ (`appVersion`, `fingerprint`, ...) pass the resolved value with `--runtime-version`.
130
+ - Responses follow the `Accept` header: multipart (the `expo-updates` default) or
131
+ `application/expo+json` for JSON-only clients (directives need multipart; otherwise `406`).
132
+ - The manifest URL also accepts `?platform=`, `?runtime-version=` and `?channel=` query parameters
133
+ as fallbacks, which is handy for debugging with `curl`.
134
+
135
+ ## Publishing
136
+
137
+ ```bash
138
+ otaship publish -m "message" # npx expo export + upload + activate (100%)
139
+ otaship publish --dist dist --runtime-version 1.4.0 # use an existing `expo export` output
140
+ otaship publish --rollout 10 --auto-rollback # staged rollout to 10% of devices
141
+ otaship publish --no-activate # upload and register only
142
+ otaship status # what is live where
143
+ ```
144
+
145
+ `publish` runs `npx expo export`, reads `dist/metadata.json`, hashes every file, asks the server
146
+ which blobs it is missing, uploads only those, then registers one update group (Android + iOS)
147
+ for the runtime version and channel. The server verifies every blob's md5 key and sha256 hash
148
+ before it accepts the update, so a partial upload can never go live.
149
+
150
+ ## Staged rollouts
151
+
152
+ ```bash
153
+ otaship publish --rollout 5
154
+ otaship rollout stage --runtime-version 1.4.0 --percent 25
155
+ otaship rollout promote --runtime-version 1.4.0 # 100%
156
+ otaship rollout abort --runtime-version 1.4.0 # everyone back to the previous update
157
+ ```
158
+
159
+ Devices are bucketed by `sha256(group + eas-client-id) % 100`, so a device stays on the same side
160
+ for the whole rollout, and each rollout picks a different slice of devices. Devices that do not
161
+ send `eas-client-id` always get the current (non-rollout) update. Only one rollout per channel at a
162
+ time; percentages can go up but not down (abort instead).
163
+
164
+ Aborting does not just stop serving the candidate: `expo-updates` never moves to an update whose
165
+ commit time is older than the one it runs, so the server re-publishes the previous update with
166
+ fresh ids and a newer timestamp (same assets, nothing re-uploaded). Devices that took the candidate
167
+ move back on their next check.
168
+
169
+ ## Auto-rollback
170
+
171
+ A staged rollout can watch its own health and abort itself.
172
+
173
+ ```bash
174
+ export OTASHIP_AUTO_ROLLBACK=true # default for new rollouts
175
+ otaship publish --rollout 10 # or --auto-rollback / --no-auto-rollback
176
+ ```
177
+
178
+ **How health is measured.** For each device served the candidate, the server records the serve
179
+ (keyed by an HMAC of `eas-client-id`, never the raw id). A launch counts as **confirmed** when:
180
+
181
+ 1. a later update check from that device reports the candidate as its running update
182
+ (`expo-current-update-id`) - this needs no app code; or
183
+ 2. the app calls `POST /health` after a successful start (recommended, faster and more precise).
184
+
185
+ When `expo-updates` cannot launch a downloaded update it falls back to the previous one, so the
186
+ device's next check reports the old id: the device is **observed** but not confirmed. Once at least
187
+ `OTASHIP_AUTO_ROLLBACK_MIN_DEVICES` devices are observed and the confirmed share falls below
188
+ `OTASHIP_AUTO_ROLLBACK_MIN_RATIO`, the rollout is aborted exactly like a manual abort, the
189
+ history records `auto_rollback` with the numbers, and an `auto_rollback` webhook fires.
190
+
191
+ Optional explicit confirmation from the app (call once, after your first screen rendered):
192
+
193
+ ```js
194
+ import * as Updates from 'expo-updates';
195
+
196
+ export async function reportLaunchHealthy() {
197
+ const token = Updates.manifest?.extra?.expoOtaServer?.healthToken;
198
+ if (!Updates.isEnabled || Updates.isEmbeddedLaunch || !Updates.updateId || !token) return;
199
+ try {
200
+ await fetch('https://updates.example.com/health', {
201
+ method: 'POST',
202
+ headers: { 'content-type': 'application/json' },
203
+ body: JSON.stringify({ updateId: Updates.updateId, token }),
204
+ });
205
+ } catch {}
206
+ }
207
+ ```
208
+
209
+ `healthToken` is the device's pseudonymous marker, embedded in the manifest it was served; a
210
+ confirmation only counts for a device that was actually served that update.
211
+
212
+ Tuning: `OTASHIP_AUTO_ROLLBACK_GRACE_SECONDS` (wait this long after a serve before judging a
213
+ device), `OTASHIP_AUTO_ROLLBACK_MIN_GAP_SECONDS` (ignore checks within this many seconds of the
214
+ serve, i.e. the same app session). Devices that download the update but report the old id because
215
+ they have not restarted yet count as unconfirmed until they do; keep the threshold conservative or
216
+ use the explicit `/health` call.
217
+
218
+ ## Rollback
219
+
220
+ ```bash
221
+ otaship rollback --runtime-version 1.4.0 # previous update (re-published)
222
+ otaship rollback --runtime-version 1.4.0 --to embedded # back to the build's embedded bundle
223
+ ```
224
+
225
+ `--to embedded` serves a `rollBackToEmbedded` directive (protocol 1). Devices already running their
226
+ embedded update get "no update"; protocol-0 clients cannot receive directives and also get "no
227
+ update". Publishing or activating an update clears the directive.
228
+
229
+ ## Dashboard
230
+
231
+ Open `https://updates.example.com/admin` and sign in with the admin token. Per runtime and channel
232
+ it shows the active update, an in-flight rollout with its percentage and health ratio, adoption
233
+ (unique devices whose last check reported each update, last 30 days), the history, and buttons for
234
+ raise / promote / abort / start rollout / make active / roll back.
235
+
236
+ Security: the session is an HMAC-signed, `HttpOnly`, `SameSite=Strict` cookie scoped to `/admin`
237
+ (set `OTASHIP_SECURE_COOKIES=false` only for plain-HTTP local testing); every action needs a
238
+ per-session CSRF token and a same-origin `Origin`/`Referer`; pages send a strict CSP and
239
+ `X-Frame-Options: DENY`; all output is HTML-escaped. Rate-limit `/admin/login` at your proxy.
240
+
241
+ ## Webhooks
242
+
243
+ ```bash
244
+ export OTASHIP_WEBHOOK_URLS="https://hooks.example.com/ota,https://chat.example.com/hook"
245
+ export OTASHIP_WEBHOOK_SECRET="long random string"
246
+ ```
247
+
248
+ Events: `publish`, `activate`, `stage`, `promote`, `abort`, `rollback`, `rollback_embedded`,
249
+ `auto_rollback`. Body: `{"event": ..., "timestamp": ..., "data": {...}}`. Headers:
250
+ `X-Otaship-Event`, `X-Otaship-Timestamp`, and
251
+ `X-Otaship-Signature: sha256=<hex HMAC-SHA256 of "<timestamp>.<body>">`. Verify in constant time
252
+ and reject old timestamps; `otaship.webhooks.verify` is a reference implementation.
253
+ Delivery is asynchronous, best effort, 3 attempts.
254
+
255
+ ## Code signing
256
+
257
+ ```bash
258
+ otaship init --signing # writes keys/certificate.pem and keys/private-key.pem
259
+ ```
260
+
261
+ Add to `app.json` (printed by `init`):
262
+
263
+ ```json
264
+ "updates": {
265
+ "codeSigningCertificate": "./keys/certificate.pem",
266
+ "codeSigningMetadata": { "keyid": "main", "alg": "rsa-v1_5-sha256" }
267
+ }
268
+ ```
269
+
270
+ Copy `private-key.pem` to the server only (never commit it) and set
271
+ `OTASHIP_SIGNING_KEY=/path/to/private-key.pem` (and `OTASHIP_SIGNING_KEYID` if not `main`).
272
+ Manifests and directives are then signed with `expo-signature`. Signing settings are part of the
273
+ native build, so a new certificate requires a new build. The key file is re-read when it changes.
274
+
275
+ ## Deployment, nginx and CDN caching
276
+
277
+ - Terminate TLS in front of the server. Set `OTASHIP_PUBLIC_URL` to the public origin; asset URLs
278
+ in manifests are built from it (or from `OTASHIP_ASSET_BASE_URL`, for example a CDN host).
279
+ - **Do not cache `/manifest` at the edge.** The response varies on `expo-platform`,
280
+ `expo-runtime-version`, `expo-channel-name`, `expo-current-update-id` and `eas-client-id`.
281
+ Most CDNs do not key on custom headers, so an edge cache would serve one platform's manifest to
282
+ another. The server sends `Cache-Control: private, no-store`; make sure your CDN honours it.
283
+ - **Do cache `/assets/` aggressively.** Names are content hashes and responses are
284
+ `public, max-age=31536000, immutable`. Serving `$OTASHIP_DATA_DIR/blobs/` directly is fastest:
285
+
286
+ ```nginx
287
+ location /assets/ {
288
+ alias /var/lib/otaship/blobs/;
289
+ add_header Cache-Control "public, max-age=31536000, immutable";
290
+ add_header Content-Security-Policy "sandbox; default-src 'none'"; # assets share the /admin origin
291
+ add_header X-Content-Type-Options nosniff;
292
+ types { application/javascript js; }
293
+ try_files $uri =404;
294
+ }
295
+ location / {
296
+ proxy_pass http://127.0.0.1:8000;
297
+ proxy_set_header Host $host;
298
+ proxy_set_header X-Forwarded-Proto $scheme;
299
+ client_max_body_size 100m; # blob uploads
300
+ }
301
+ ```
302
+
303
+ - Back up `$OTASHIP_DATA_DIR` (blobs, update documents, `telemetry.secret`). Storage layout and
304
+ the extension point for S3/R2 are described in [docs/STORAGE.md](docs/STORAGE.md).
305
+
306
+ ## Configuration reference
307
+
308
+ | Variable | Default | Purpose |
309
+ | --- | --- | --- |
310
+ | `OTASHIP_DATA_DIR` | `./data` | Blobs, update documents, telemetry |
311
+ | `OTASHIP_ADMIN_TOKEN` | (unset: admin disabled) | Bearer token for the admin API and dashboard (16+ chars) |
312
+ | `OTASHIP_PUBLIC_URL` | request URL | Public origin used for asset URLs |
313
+ | `OTASHIP_ASSET_BASE_URL` | `$PUBLIC_URL/assets` | Serve assets from another host (CDN) |
314
+ | `OTASHIP_DEFAULT_CHANNEL` | `production` | Channel for builds without `expo-channel-name` |
315
+ | `OTASHIP_SIGNING_KEY` / `_KEYID` | unset / `main` | Code signing private key (PEM) |
316
+ | `OTASHIP_MAX_BLOB_MB` | `100` | Upload size limit per file |
317
+ | `OTASHIP_HISTORY_MAX` | `100` | History entries kept per channel |
318
+ | `OTASHIP_SECURE_COOKIES` | `true` | `Secure` flag on the dashboard cookie |
319
+ | `OTASHIP_WEBHOOK_URLS` / `_SECRET` | unset | Webhook targets and HMAC secret |
320
+ | `OTASHIP_AUTO_ROLLBACK` | `false` | Auto-rollback default for new rollouts |
321
+ | `OTASHIP_AUTO_ROLLBACK_MIN_DEVICES` | `50` | Observed devices needed before deciding |
322
+ | `OTASHIP_AUTO_ROLLBACK_MIN_RATIO` | `0.5` | Abort below this confirmed share |
323
+ | `OTASHIP_AUTO_ROLLBACK_GRACE_SECONDS` | `21600` | Wait after a serve before judging a device |
324
+ | `OTASHIP_AUTO_ROLLBACK_MIN_GAP_SECONDS` | `60` | Ignore checks this soon after a serve |
325
+
326
+ CLI: `OTASHIP_SERVER` (or `.otaship.json`) and `OTASHIP_ADMIN_TOKEN`. The token is never written
327
+ to disk by the CLI.
328
+
329
+ ## Comparison with EAS Update
330
+
331
+ A factual summary as of writing; EAS Update changes over time, so check
332
+ [its documentation and pricing](https://docs.expo.dev/eas-update/introduction/) for current details.
333
+
334
+ | | otaship | EAS Update |
335
+ | --- | --- | --- |
336
+ | Hosting | You run it (one Python process + files) | Managed by Expo |
337
+ | Pricing model | Your server/bandwidth; no per-user fees | Plans priced by monthly active users and bandwidth, with a free tier |
338
+ | Client | Stock `expo-updates` | Stock `expo-updates` |
339
+ | Channels, runtime versions, code signing | Yes | Yes |
340
+ | Percentage rollouts | Yes | Yes |
341
+ | Rollback to previous / to embedded | Yes | Yes |
342
+ | Automatic rollback on failed launches | Yes (opt-in, per rollout) | Not a built-in feature to our knowledge |
343
+ | Dashboard | Built-in, self-hosted | Expo website |
344
+ | Webhooks | Signed, per event | See Expo docs |
345
+ | Storage / CDN | Your choice | Expo's |
346
+ | Branches decoupled from channels, insights, EAS Build/Workflows integration | No | Yes |
347
+ | Operational burden (uptime, TLS, backups) | Yours | Expo's |
348
+
349
+ ## Limitations
350
+
351
+ - One server process owns the data directory; the per-channel lock is `flock`, so multiple
352
+ instances need a shared POSIX filesystem (not NFS without lock support). S3/R2 blob storage is an
353
+ extension point, not built in yet.
354
+ - Branches are not modelled separately: a channel *is* the branch (`metadata.branchName`).
355
+ - Rollout targeting is by percentage only. Targeting by app version or other headers is on the roadmap.
356
+ - Telemetry (adoption, health) is per-installation SQLite and best effort; it is not analytics.
357
+ - Web (`expo export --platform web`) is not served; this is for native iOS/Android updates.
358
+ - Auto-rollback trusts `eas-client-id`, which devices do not authenticate. Someone who can send many
359
+ update checks with invented client ids can make a rollout look unhealthy and trigger an abort. The
360
+ abort only returns devices to the previous known-good update, but if that matters for you, keep
361
+ `MIN_DEVICES` high, rate-limit `/manifest` per IP at your proxy, or leave auto-rollback off and
362
+ watch the health ratio in the dashboard instead.
363
+ - `/health` is unauthenticated by design (it can only confirm a serve the server already made); put
364
+ normal request-rate limits in front of the server.
365
+
366
+ ## Roadmap
367
+
368
+ - Targeting rules beyond percentage (app version, platform, custom headers).
369
+ - S3 / R2 blob storage backend.
370
+ - Asset patching / bundle diffs.
371
+
372
+ ## License
373
+
374
+ MIT, see [LICENSE](LICENSE). Contributions welcome, see [CONTRIBUTING.md](CONTRIBUTING.md).