python-ship 0.2.0__tar.gz → 0.4.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.
- {python_ship-0.2.0/src/python_ship.egg-info → python_ship-0.4.0}/PKG-INFO +382 -181
- {python_ship-0.2.0 → python_ship-0.4.0}/README.md +380 -180
- {python_ship-0.2.0 → python_ship-0.4.0}/docs/adding-a-service.md +11 -9
- {python_ship-0.2.0 → python_ship-0.4.0}/docs/build-environment.md +5 -1
- python_ship-0.4.0/docs/standalone-runtimes.md +97 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/docs/upgrading.md +25 -3
- {python_ship-0.2.0 → python_ship-0.4.0}/pyproject.toml +2 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/schema/service-environment.json +2 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/schema/ship.schema.json +28 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/__init__.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/adapters.py +28 -3
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/capabilities.py +26 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/cli.py +311 -95
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/compose.py +40 -14
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/config.py +26 -11
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/contracts.py +13 -1
- python_ship-0.4.0/src/python_ship/environment.py +291 -0
- python_ship-0.4.0/src/python_ship/image_build.py +143 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/init.py +298 -76
- python_ship-0.4.0/src/python_ship/layout.py +50 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/mutagen.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/package_managers.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/plugins.py +22 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/portable.py +7 -0
- python_ship-0.4.0/src/python_ship/ports.py +120 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/production.py +2 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/release.py +4 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/runtime.py +9 -7
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/schema/service-environment.json +2 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/schema/ship.schema.json +28 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/security.py +2 -1
- python_ship-0.4.0/src/python_ship/service_setup.py +81 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/services.py +104 -5
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/storage.py +9 -3
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/stubs.py +23 -21
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/templates/Dockerfile +12 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/templates/check-python-security-floor.py +1 -1
- python_ship-0.4.0/src/python_ship/templates/launcher +49 -0
- python_ship-0.4.0/src/python_ship/terminal.py +75 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/wizard.py +52 -6
- {python_ship-0.2.0 → python_ship-0.4.0/src/python_ship.egg-info}/PKG-INFO +382 -181
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship.egg-info/SOURCES.txt +8 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship.egg-info/requires.txt +1 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_build_environment.py +2 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_cli.py +88 -14
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_compose.py +43 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_config.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_development.py +17 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_portable.py +11 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_production.py +3 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_services.py +10 -0
- python_ship-0.4.0/tests/test_environment.py +99 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_extensions.py +1 -1
- python_ship-0.4.0/tests/test_image_build.py +84 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_init.py +170 -28
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_mutagen.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_package_managers.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_plugins.py +13 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_portable_services.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_production.py +13 -11
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_release_contract.py +1 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_runtime.py +7 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_security.py +2 -2
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_servers.py +1 -1
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_services.py +41 -4
- python_ship-0.4.0/tests/test_wizard_terminal.py +92 -0
- python_ship-0.2.0/src/python_ship/environment.py +0 -77
- python_ship-0.2.0/tests/test_environment.py +0 -55
- python_ship-0.2.0/tests/test_wizard_terminal.py +0 -46
- {python_ship-0.2.0 → python_ship-0.4.0}/LICENSE.md +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/MANIFEST.in +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/docs/releasing.md +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-adapter/README.md +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-adapter/pyproject.toml +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-adapter/src/ship_example_starlette_adapter/__init__.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-service/README.md +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-service/pyproject.toml +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/examples/community-service/src/ship_example_http_service/__init__.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/schema/ship-release.schema.json +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/setup.cfg +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/__main__.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/build_environment.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/portable_data.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/py.typed +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/schema/ship-release.schema.json +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/servers.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/templates/app-entrypoint.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/templates/garage/Dockerfile +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/templates/garage/garage.toml +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship/uv.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship.egg-info/dependency_links.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship.egg-info/entry_points.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/src/python_ship.egg-info/top_level.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/__init__.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/manage.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/project/__init__.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/project/asgi.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/project/settings.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/project/urls.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/project/views.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/django_app/requirements.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/fastapi_app/main.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/fastapi_app/requirements.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/flask_app/app.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/flask_app/requirements.txt +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/fixtures/plain_asgi/main.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/helpers.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_adapters.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_capabilities.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_release.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_docker_tooling.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_plain_asgi_http.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_release.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_schema.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_shared_contract.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/test_uv.py +0 -0
- {python_ship-0.2.0 → python_ship-0.4.0}/tests/vite.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-ship
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Framework-agnostic, cross-platform Docker development environment and portable releases for Python web apps.
|
|
5
5
|
Author: python-ship
|
|
6
6
|
License-Expression: MIT
|
|
@@ -30,6 +30,7 @@ Description-Content-Type: text/markdown
|
|
|
30
30
|
License-File: LICENSE.md
|
|
31
31
|
Requires-Dist: typer<1,>=0.27
|
|
32
32
|
Requires-Dist: questionary<3,>=2.1
|
|
33
|
+
Requires-Dist: rich>=13
|
|
33
34
|
Dynamic: license-file
|
|
34
35
|
|
|
35
36
|
# python-ship
|
|
@@ -41,30 +42,33 @@ Dynamic: license-file
|
|
|
41
42
|
[](https://pypistats.org/packages/python-ship)
|
|
42
43
|
[](https://github.com/ship-ecosystem/python-ship/blob/main/LICENSE.md)
|
|
43
44
|
|
|
44
|
-
A
|
|
45
|
-
Python web apps
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
artifact, for any ASGI or WSGI app — a plain callable, Django, FastAPI or
|
|
49
|
-
Flask built in, anything else through a community adapter.
|
|
45
|
+
A cross-platform Docker development environment and portable production
|
|
46
|
+
release builder for Python web apps. Ship supports Django, FastAPI, Flask,
|
|
47
|
+
and plain ASGI or WSGI apps, with Uvicorn, Hypercorn, Gunicorn, and Granian.
|
|
48
|
+
Community packages can add frameworks, servers, or services.
|
|
50
49
|
|
|
51
|
-
Ship
|
|
52
|
-
|
|
50
|
+
Python Ship and [PHP Ship](https://github.com/ship-ecosystem/php-ship) share
|
|
51
|
+
the same CLI workflow, `ship.json` vocabulary, and portable release format.
|
|
53
52
|
|
|
54
53
|
## Contents
|
|
55
54
|
|
|
56
55
|
- [Why not just write a Compose file?](#why-not-just-write-a-compose-file)
|
|
57
56
|
- [Requirements](#requirements)
|
|
58
57
|
- [Quick start](#quick-start)
|
|
58
|
+
- [Upgrading the project layout](#upgrading-the-project-layout)
|
|
59
|
+
- [Choosing services](#choosing-services)
|
|
59
60
|
- [Commands](#commands)
|
|
61
|
+
- [Image build output](#image-build-output)
|
|
62
|
+
- [Running setup commands before startup](#running-setup-commands-before-startup)
|
|
60
63
|
- [Services](#services)
|
|
61
|
-
- [
|
|
64
|
+
- [Broadcasting](#broadcasting)
|
|
65
|
+
- [Web servers and app entry points](#web-servers-asgi-and-wsgi)
|
|
66
|
+
- [Browser testing](#browser-testing-testing)
|
|
62
67
|
- [Configuration (`ship.json`)](#configuration-shipjson)
|
|
63
68
|
- [Adding a service later](#adding-a-service-later)
|
|
64
69
|
- [Multiple instances of a service](#multiple-instances-of-a-service)
|
|
65
70
|
- [Custom service names and an external network](#custom-service-names-and-an-external-network)
|
|
66
71
|
- [Dependencies and `ship uv`](#dependencies-and-ship-uv)
|
|
67
|
-
- [Web servers: ASGI and WSGI](#web-servers-asgi-and-wsgi)
|
|
68
72
|
- [Background tasks (Celery)](#background-tasks-celery)
|
|
69
73
|
- [Production releases](#production-releases)
|
|
70
74
|
- [Python security floor](#python-security-floor)
|
|
@@ -126,61 +130,98 @@ otherwise rebuild by hand:
|
|
|
126
130
|
## Quick start
|
|
127
131
|
|
|
128
132
|
```sh
|
|
129
|
-
uv tool install python-ship
|
|
133
|
+
uv tool install python-ship
|
|
130
134
|
cd your-project
|
|
131
|
-
ship init
|
|
132
|
-
ship up
|
|
133
|
-
ship manage migrate # Django only: registered when manage.py is detected
|
|
134
|
-
ship uv add httpx # add a dependency; `ship up` rebuilds the image
|
|
135
|
-
ship shell # drop into the app container
|
|
136
|
-
ship down
|
|
135
|
+
ship init
|
|
136
|
+
ship up
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
Open the URL printed by `ship up`, normally `http://127.0.0.1:8000`. Run
|
|
140
|
+
`ship manage migrate` if a Django project needs migrations, and `ship down`
|
|
141
|
+
when you finish.
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
`ship init` detects Django, FastAPI and Flask, including Flask app factories,
|
|
144
|
+
then suggests an import target and compatible web server. To start from an
|
|
145
|
+
empty directory, use a [plain ASGI or WSGI example](docs/standalone-runtimes.md).
|
|
146
|
+
You can install the CLI with `pipx install python-ship`, or add it to a uv
|
|
147
|
+
project with `uv add --dev python-ship` and run commands as `uv run ship ...`.
|
|
148
|
+
|
|
149
|
+
Commit `ship.json`, the published files under `docker/ship/`, the project-root
|
|
150
|
+
`ship` launcher, and `.env.example`. Use the installed CLI or run the launcher
|
|
151
|
+
as `./ship` on Linux and macOS or `python ship` on Windows.
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
Dockerfile and its security check) into your project root — both are meant to
|
|
152
|
-
be committed. In scripts and CI, pass everything as options and add
|
|
153
|
-
`--no-interaction`:
|
|
153
|
+
For scripts and CI, use `--no-interaction` (`-n`) with explicit choices.
|
|
154
154
|
|
|
155
155
|
```sh
|
|
156
|
-
ship init -n --framework django --app project.asgi:application
|
|
156
|
+
ship init -n --framework django --app project.asgi:application \
|
|
157
|
+
--server hypercorn --database postgres --cache redis
|
|
157
158
|
```
|
|
158
159
|
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
### Upgrading the project layout
|
|
161
|
+
|
|
162
|
+
Run `ship init` after updating Python Ship. It publishes the current layout in
|
|
163
|
+
`docker/ship/` and archives an older managed `ship/` directory in
|
|
164
|
+
`docker/ship-legacy/` to make room for the launcher. Review customizations and
|
|
165
|
+
update paths in your Compose override. See the
|
|
166
|
+
[upgrade guide](docs/upgrading.md) for Dockerfile and data migrations.
|
|
167
|
+
|
|
168
|
+
### Choosing services
|
|
169
|
+
|
|
170
|
+
The wizard asks for the project name, framework and app target, then offers
|
|
171
|
+
servers compatible with the app's interface. Select the kinds of service you
|
|
172
|
+
need, then choose one provider per selected kind. Each provider list ends with
|
|
173
|
+
**None**. The wizard offers [named instances](#multiple-instances-of-a-service)
|
|
174
|
+
for eligible services in a separate step.
|
|
175
|
+
|
|
176
|
+
Ship also asks about Python, Compose service names, production processes,
|
|
177
|
+
external networks, and the host ports to publish in each environment. New
|
|
178
|
+
projects start with Python 3.14 and the app's HTTP port published in both
|
|
179
|
+
development and production. Review the summary before writing changes. In the
|
|
180
|
+
terminal wizard, press **Ctrl+U** to return to the previous prompt.
|
|
181
|
+
|
|
182
|
+
After confirmation, the wizard shows a table for each environment file with
|
|
183
|
+
its values, the service or group that uses each key, and what changed.
|
|
184
|
+
Credentials appear masked.
|
|
185
|
+
|
|
186
|
+
| File | What Ship fills in |
|
|
187
|
+
|---|---|
|
|
188
|
+
| `.env` | Development defaults, managed connection settings such as `DB_HOST`, and selected host ports. If the file is missing, Ship starts with `.env.example` when available. |
|
|
189
|
+
| `.env.example` | Known connection defaults and blank placeholders for credentials and custom values. |
|
|
190
|
+
| `.env.production` | Production connection settings and placeholders for required credentials. Ship omits settings used only by development tools. |
|
|
191
|
+
|
|
192
|
+
Ship preserves configurable credentials and suggests the Python client
|
|
193
|
+
packages your selected services need. Add them to your application
|
|
194
|
+
dependencies and rebuild with `ship up`. Use [Production releases](#production-releases)
|
|
195
|
+
when you are ready to build a deployment.
|
|
161
196
|
|
|
162
197
|
## Commands
|
|
163
198
|
|
|
199
|
+
Run `ship --help` for the grouped command list or `ship help <command>` for
|
|
200
|
+
options and examples.
|
|
201
|
+
|
|
164
202
|
| Command | What it does |
|
|
165
203
|
|---|---|
|
|
166
|
-
| `ship init` |
|
|
167
|
-
| `ship up` | Regenerates `ship/docker-compose.generated.yml` from `ship.json`,
|
|
204
|
+
| `ship init` | Picks the framework, app target, server, services and published ports. Writes `ship.json`, the project launcher, and Docker templates under `docker/ship/`. Run `ship init --help` for automation flags. |
|
|
205
|
+
| `ship up` | Regenerates `docker/ship/docker-compose.generated.yml` from `ship.json`, builds the development images, then starts the stack and waits for container healthchecks and an HTTP response. |
|
|
168
206
|
| `ship build` | Builds every project-owned production image, tagged locally. Needs `.env.production` as soon as a selected service has a required credential. See [Production releases](#production-releases). |
|
|
169
207
|
| `ship release --tag <tag> [--force] [--no-env]` | Builds the same images (re-tagged) and assembles the portable release under `dist/ship/<tag>/`. |
|
|
170
208
|
| `ship down [--volumes]` | `docker compose down`. `--volumes` also deletes named volumes (database and storage data — use with care). |
|
|
209
|
+
| `ship ps [OPTIONS] [SERVICE...]` | Shows development containers, including stopped ones, and their published ports. Passes filters and formatting options to Compose. |
|
|
210
|
+
| `ship run [--env NAME=value] [--] COMMAND [ARGS...]` | Runs a setup command in a disposable development container with the project bind-mounted. Works before `ship up`. |
|
|
171
211
|
| `ship exec <service> <cmd...>` | Runs a command inside a running service. The generic escape hatch every shortcut below wraps. |
|
|
172
212
|
| `ship shell [service]` | Opens a shell (`sh`) in a service; defaults to the app. |
|
|
173
213
|
| `ship logs [service] [-f]` | Shows logs for one service, or all of them. `-f`/`--follow` streams. |
|
|
174
214
|
| `ship db [instance]` | Opens the database's client (`psql`/`mysql`/`mariadb`/`mongosh`/`sqlcmd`) with credentials from its own container. Name one of `additionalServices`' databases to open that instance instead. |
|
|
175
|
-
| `ship
|
|
176
|
-
| `ship doctor` | Shows
|
|
215
|
+
| `ship check` | Validates `ship.json`, published files, both Compose models, and required production settings without Docker. Groups errors and warnings. |
|
|
216
|
+
| `ship doctor` | Shows project and runtime versions, published templates, and a color-coded table of development service states, health, images, and ports. Lists problems with recovery commands. |
|
|
177
217
|
| `ship uv <args...>` | Runs uv dependency commands (`add`, `remove`, `lock`, `tree`, ...) in a temporary container with the project's Python. See [Dependencies](#dependencies-and-ship-uv). |
|
|
178
218
|
| `ship npm/pnpm/yarn <args...>` | Runs the selected, exactly pinned tool in the Node frontend service. The manifest and lockfile remain authoritative. |
|
|
179
|
-
| `ship package-manager TOOL[@VERSION] [--yes]` | Switches the frontend tool
|
|
219
|
+
| `ship package-manager TOOL[@VERSION] [--yes]` | Switches the frontend tool, records the pin and reinstalls. Uses a disposable Node container before the stack starts. Restores recorded files and dependencies after installation failure. |
|
|
180
220
|
| `ship test [-- ARGS...]` | Runs Cypress on demand, or Python pytest against the selected Selenium/Playwright service. Install/configure the application's test client first. |
|
|
181
221
|
| `ship manage <args...>` | Runs `python manage.py` in the app — only registered for Django projects. |
|
|
182
222
|
| `ship flask <args...>` | Runs the `flask` CLI in the app (`FLASK_APP` is set) — only registered for Flask projects. A community adapter registers its own commands the same way. |
|
|
183
223
|
| `ship --version` | Shows the installed python-ship version. |
|
|
224
|
+
| `ship help [COMMAND]` | Lists commands by workflow or shows help for one command. |
|
|
184
225
|
|
|
185
226
|
Every proxied command forwards its arguments exactly as typed (including
|
|
186
227
|
flags such as `ship manage migrate --database=other`), and returns the inner
|
|
@@ -188,99 +229,148 @@ command's exit code. `--project-directory PATH` before any command runs it
|
|
|
188
229
|
against another project. Without a terminal (CI, piped input), `exec`-style
|
|
189
230
|
commands pass `-T` to Compose, so `ship db < dump.sql` works.
|
|
190
231
|
|
|
232
|
+
### Image build output
|
|
233
|
+
|
|
234
|
+
Ship shows a spinner and the latest Docker build step on a dimmed line below
|
|
235
|
+
it. CI and non-interactive sessions show a plain progress line. Docker still
|
|
236
|
+
uses its build cache.
|
|
237
|
+
Successful build logs are hidden by default. A failed build prints Docker's
|
|
238
|
+
diagnostics and returns Docker's exit code.
|
|
239
|
+
|
|
240
|
+
Once the build finishes, `ship up` shows Compose's container startup progress.
|
|
241
|
+
The same build display applies to production `build` and `release`, and to
|
|
242
|
+
`ship test` when it builds the Cypress image. Test output streams live.
|
|
243
|
+
|
|
244
|
+
To stream the full build log, put `-v` or `--verbose` before the command:
|
|
245
|
+
|
|
246
|
+
```sh
|
|
247
|
+
ship -v up
|
|
248
|
+
ship -v build
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Running setup commands before startup
|
|
252
|
+
|
|
253
|
+
After `ship init`, use `ship run` for commands that need your development
|
|
254
|
+
Python or Node environment. The temporary container mounts the project, so
|
|
255
|
+
files it writes there persist. Ship passes through command output and exit
|
|
256
|
+
status, and removes the container when the command exits. It starts without
|
|
257
|
+
dependent services or published ports. Run migrations and other commands
|
|
258
|
+
that need the database after `ship up`.
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
ship run python --version
|
|
262
|
+
ship run --env DJANGO_SETTINGS_MODULE=project.settings -- python manage.py check
|
|
263
|
+
ship run npm ci # with the Node service selected and a package-lock.json
|
|
264
|
+
ship up
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Frontend setup commands such as `ship npm ci` can also use a disposable Node
|
|
268
|
+
container when the frontend service is stopped.
|
|
269
|
+
|
|
191
270
|
## Services
|
|
192
271
|
|
|
193
|
-
`ship init`
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
272
|
+
`ship init` selects one provider per group. Use
|
|
273
|
+
[`additionalServices`](#multiple-instances-of-a-service) for extra named
|
|
274
|
+
instances of supported providers. Ship creates containers, adds health checks
|
|
275
|
+
where available, and supplies connection settings. Your app declares its
|
|
276
|
+
client dependencies and connects using those settings.
|
|
277
|
+
|
|
278
|
+
### Databases (`database`)
|
|
198
279
|
|
|
199
280
|
| Service | Wired automatically | Still needed in the app |
|
|
200
281
|
|---|---|---|
|
|
201
|
-
| PostgreSQL (`postgres`,
|
|
202
|
-
| MySQL (`mysql`) | The
|
|
203
|
-
| MariaDB (`mariadb`) | `
|
|
204
|
-
| MongoDB (`mongodb`) | Separate
|
|
205
|
-
| SQL Server (`sqlserver`) |
|
|
206
|
-
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
282
|
+
| PostgreSQL (`postgres`, alias `pgsql`) | `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` and `ship db` | A driver such as `psycopg[binary]` |
|
|
283
|
+
| MySQL (`mysql`) | The `DB_*` settings, a separate root credential, and `ship db` | A driver such as `mysqlclient` or `PyMySQL` |
|
|
284
|
+
| MariaDB (`mariadb`) | The `DB_*` settings, a separate root credential, and `ship db` | A MySQL/MariaDB driver |
|
|
285
|
+
| MongoDB (`mongodb`) | Separate app and admin users, `MONGODB_DATABASE`, and an encoded `MONGODB_URI` at app startup | A client such as `pymongo` and your framework's MongoDB backend, if needed |
|
|
286
|
+
| SQL Server (`sqlserver`) | An application database and login, `DB_*` settings, and `ship db`. The image uses linux/amd64 and defaults to Developer edition. | A driver such as `pymssql` or `pyodbc` with its native driver. Set `MSSQL_PID` in `.env.production` to select the edition for deployment. |
|
|
287
|
+
| ClickHouse (`clickhouse`) | `CLICKHOUSE_*` settings, an authenticated `ship db` console, and a persistent volume | A driver such as `clickhouse-connect` over HTTP or `clickhouse-driver` for the native protocol. Set `CLICKHOUSE_PASSWORD` in `.env.production` |
|
|
288
|
+
|
|
289
|
+
ClickHouse uses HTTP on `CLICKHOUSE_HTTP_URL` (8123) and the native protocol
|
|
290
|
+
on `CLICKHOUSE_HOST` and `CLICKHOUSE_PORT` (9000). Pass `CLICKHOUSE_DB`,
|
|
291
|
+
`CLICKHOUSE_USER`, and `CLICKHOUSE_PASSWORD` to the client. Add a named
|
|
292
|
+
instance to keep another primary database. [ClickHouse Python integration](https://clickhouse.com/integrations/python)
|
|
293
|
+
|
|
294
|
+
```sh
|
|
295
|
+
ship init --no-interaction --database postgres --additional-service database=clickhouse:warehouse
|
|
296
|
+
ship up
|
|
297
|
+
ship db warehouse
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The named instance uses `WAREHOUSE_CLICKHOUSE_*` variables, including the
|
|
301
|
+
required `WAREHOUSE_CLICKHOUSE_PASSWORD` in `.env.production`. Select the
|
|
302
|
+
HTTP or native port in port publishing when a host client needs access.
|
|
303
|
+
|
|
304
|
+
For example, Django can configure PostgreSQL and Redis from the container's
|
|
305
|
+
environment in `settings.py`.
|
|
223
306
|
|
|
224
307
|
```python
|
|
225
308
|
import os
|
|
226
309
|
|
|
227
|
-
DATABASES = {
|
|
228
|
-
"
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
310
|
+
DATABASES = {
|
|
311
|
+
"default": {
|
|
312
|
+
"ENGINE": "django.db.backends.postgresql",
|
|
313
|
+
"HOST": os.environ["DB_HOST"],
|
|
314
|
+
"PORT": os.environ["DB_PORT"],
|
|
315
|
+
"NAME": os.environ["DB_DATABASE"],
|
|
316
|
+
"USER": os.environ["DB_USERNAME"],
|
|
317
|
+
"PASSWORD": os.environ["DB_PASSWORD"],
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
CACHES = {
|
|
321
|
+
"default": {
|
|
322
|
+
"BACKEND": "django.core.cache.backends.redis.RedisCache",
|
|
323
|
+
"LOCATION": os.environ["REDIS_URL"],
|
|
324
|
+
}
|
|
325
|
+
}
|
|
235
326
|
```
|
|
236
327
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
328
|
+
FastAPI, Flask, and plain apps can pass the same settings directly to their
|
|
329
|
+
clients. See the working [Django](tests/fixtures/django_app) and
|
|
330
|
+
[FastAPI](tests/fixtures/fastapi_app) examples used in the Docker tests.
|
|
331
|
+
|
|
332
|
+
### Cache (`cache`)
|
|
333
|
+
|
|
334
|
+
| Service | Wired automatically | Still needed in the app |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| Redis (`redis`) | `REDIS_URL`, `REDIS_HOST`, `REDIS_PORT`, and persistent storage | The `redis` client |
|
|
337
|
+
| Valkey (`valkey`) | The same Redis-compatible settings and persistent storage | A Redis-compatible client |
|
|
338
|
+
| Memcached (`memcached`) | `MEMCACHED_HOST` and `MEMCACHED_PORT` | A client such as `pymemcache`. Use it for ephemeral cache data. |
|
|
339
|
+
|
|
340
|
+
### Search (`search`)
|
|
341
|
+
|
|
342
|
+
| Service | Wired automatically | Still needed in the app |
|
|
343
|
+
|---|---|---|
|
|
344
|
+
| Meilisearch (`meilisearch`) | `MEILISEARCH_URL`, `MEILISEARCH_HOST` and `MEILISEARCH_KEY` | A Meilisearch client or an HTTP client |
|
|
345
|
+
| Elasticsearch (`elasticsearch`) | An authenticated single-node service with `ELASTICSEARCH_HOST`, `ELASTICSEARCH_USERNAME` and `ELASTICSEARCH_PASSWORD` | An Elasticsearch client and enough host resources for the search node |
|
|
346
|
+
| Typesense (`typesense`) | Persistent storage and `TYPESENSE_HOST`, `TYPESENSE_PORT`, `TYPESENSE_PROTOCOL` and `TYPESENSE_API_KEY` | A Typesense or HTTP client and the application's collection schemas |
|
|
347
|
+
|
|
348
|
+
### Object storage (`storage`)
|
|
349
|
+
|
|
350
|
+
| Service | Wired automatically | Still needed in the app |
|
|
351
|
+
|---|---|---|
|
|
352
|
+
| Garage (`garage`) | An S3 endpoint with a default key and bucket | An S3 client |
|
|
353
|
+
| SeaweedFS (`seaweedfs`), RustFS (`rustfs`), Silo (`silo`) | Authenticated S3 endpoints, with a development console for Silo when published | An S3 client. Create the bucket named by `AWS_BUCKET` before storing objects. |
|
|
245
354
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
355
|
+
All four provide `AWS_ENDPOINT`, `AWS_USE_PATH_STYLE_ENDPOINT`,
|
|
356
|
+
`AWS_DEFAULT_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and
|
|
357
|
+
`AWS_BUCKET`. With boto3, set the endpoint explicitly and use path-style
|
|
358
|
+
addressing.
|
|
249
359
|
|
|
250
360
|
```python
|
|
251
361
|
import os
|
|
252
|
-
from playwright.sync_api import sync_playwright
|
|
253
362
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
363
|
+
import boto3
|
|
364
|
+
from botocore.config import Config
|
|
365
|
+
|
|
366
|
+
s3 = boto3.client(
|
|
367
|
+
"s3",
|
|
368
|
+
endpoint_url=os.environ["AWS_ENDPOINT"],
|
|
369
|
+
config=Config(s3={"addressing_style": "path"}),
|
|
370
|
+
)
|
|
258
371
|
```
|
|
259
372
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
| Service | Image |
|
|
263
|
-
|---|---|
|
|
264
|
-
| PostgreSQL | `postgres:18.7-alpine` |
|
|
265
|
-
| MySQL | `mysql:9.7.4` |
|
|
266
|
-
| Redis | `redis:8.10.3-alpine3.23` |
|
|
267
|
-
| RabbitMQ | `rabbitmq:4.4.1-management-alpine` |
|
|
268
|
-
| Mailpit | `axllent/mailpit:v1.34.0` |
|
|
269
|
-
| Meilisearch | `getmeili/meilisearch:v1.57.0` |
|
|
270
|
-
| Garage | `dxflrs/garage:v2.5.0` (built from `ship/garage/`) |
|
|
271
|
-
| SeaweedFS | `ghcr.io/chrislusf/seaweedfs:4.47` |
|
|
272
|
-
| RustFS | `rustfs/rustfs:1.0.6` |
|
|
273
|
-
| Silo | `pgsty/silo:RELEASE.2026-11-12T00-00-00Z` |
|
|
274
|
-
| Selenium | `selenium/standalone-chromium:4.53.0-20261120` |
|
|
275
|
-
| Playwright | `mcr.microsoft.com/playwright:v1.65.1-noble` |
|
|
276
|
-
| Node.js | Reviewed digest-pinned Node 22/24/26 image (`node` field) |
|
|
277
|
-
|
|
278
|
-
Ship rebuilds PostgreSQL, MySQL, Typesense, Elasticsearch, SeaweedFS and the development-only Cypress image
|
|
279
|
-
with distribution package updates. Portable releases include the rebuilt
|
|
280
|
-
production service images. Run `ship init --force` after reviewing local template
|
|
281
|
-
edits to pick up the updated Python runtime Dockerfile.
|
|
282
|
-
|
|
283
|
-
### Silo on older CPUs
|
|
373
|
+
#### Silo on older CPUs
|
|
284
374
|
|
|
285
375
|
Silo publishes two images of every release, and they don't run on the same
|
|
286
376
|
set of machines:
|
|
@@ -306,6 +396,112 @@ To check a Linux machine, run
|
|
|
306
396
|
searched)` means the standard image runs there. Both images are the same Silo
|
|
307
397
|
release on the same data volume, so you can switch later.
|
|
308
398
|
|
|
399
|
+
### Mail (`mail`)
|
|
400
|
+
|
|
401
|
+
| Service | Wired automatically | Still needed in the app |
|
|
402
|
+
|---|---|---|
|
|
403
|
+
| Mailpit (`mailpit`) | `MAIL_HOST` and `MAIL_PORT` for SMTP. Its development web UI defaults to `127.0.0.1:8025` when published. | Point your framework's mail settings or Python's `smtplib` at the SMTP address. |
|
|
404
|
+
|
|
405
|
+
### Message broker (`broker`) and background workers (`tasks`)
|
|
406
|
+
|
|
407
|
+
| Service | Wired automatically | Still needed in the app |
|
|
408
|
+
|---|---|---|
|
|
409
|
+
| RabbitMQ (`rabbitmq`) | `AMQP_URL` and `RABBITMQ_*` connection settings. Its development management UI defaults to `127.0.0.1:15672` when published. | An AMQP client such as `kombu` or `pika`, or Celery |
|
|
410
|
+
| Celery (`celery`) | A worker using the app image, with `CELERY_APP`, `CELERY_BROKER_URL` and `CELERY_RESULT_BACKEND` | Celery and your task definitions. See [Background tasks](#background-tasks-celery). |
|
|
411
|
+
|
|
412
|
+
### Broadcasting
|
|
413
|
+
|
|
414
|
+
| Service | Wired automatically | Still needed in the app |
|
|
415
|
+
|---|---|---|
|
|
416
|
+
| Centrifugo (`centrifugo`) | Internal `CENTRIFUGO_URL`, API key and token secret, and browser WebSocket address `VITE_CENTRIFUGO_URL`. Its development endpoint defaults to `127.0.0.1:8001` when published. | Publish from the backend and supply authorized connection tokens to browser clients. |
|
|
417
|
+
| Mercure (`mercure`) | A Server-Sent Events hub with internal `MERCURE_URL`, browser-facing `MERCURE_PUBLIC_URL`, and signing settings. Its development endpoint defaults to `localhost:8002` when published. | Publish through the hub with a signed token and subscribe in the browser with an SSE client. |
|
|
418
|
+
|
|
419
|
+
#### Connecting to Centrifugo
|
|
420
|
+
|
|
421
|
+
Post JSON with a `channel` and `data` to `CENTRIFUGO_URL` plus
|
|
422
|
+
`/api/publish`. Send `CENTRIFUGO_API_KEY` in the `X-API-Key` header and check
|
|
423
|
+
the body for an `error` field. The backend signs client connection tokens
|
|
424
|
+
using `CENTRIFUGO_TOKEN_SECRET`. Browser clients connect to
|
|
425
|
+
`VITE_CENTRIFUGO_URL` and subscribe to channels your application authorizes.
|
|
426
|
+
[Centrifugo server API](https://centrifugal.dev/docs/server/server_api)
|
|
427
|
+
|
|
428
|
+
Set `CENTRIFUGO_API_KEY`, `CENTRIFUGO_TOKEN_SECRET` and a space-separated
|
|
429
|
+
`CENTRIFUGO_ALLOWED_ORIGINS` in `.env.production`. Point the browser at your
|
|
430
|
+
public `wss://` endpoint and route WebSockets to Centrifugo's container port
|
|
431
|
+
`8000`.
|
|
432
|
+
|
|
433
|
+
#### Centrifugo with Redis
|
|
434
|
+
|
|
435
|
+
Centrifugo uses its in-memory engine by default. To share broadcasts across
|
|
436
|
+
several Centrifugo servers, set `CENTRIFUGO_ENGINE=redis` in `.env` or
|
|
437
|
+
`.env.production`. Ship derives the Redis address from the selected Redis
|
|
438
|
+
or Valkey cache, including a custom Compose service name. Set
|
|
439
|
+
`CENTRIFUGO_REDIS_ADDRESS` explicitly for an external server and to make
|
|
440
|
+
multiple Centrifugo deployments use the same Redis instance.
|
|
441
|
+
|
|
442
|
+
#### Connecting to Mercure
|
|
443
|
+
|
|
444
|
+
Publish form-encoded `topic` and `data` fields to `MERCURE_URL` with a bearer
|
|
445
|
+
token that grants publication on that topic. Use `MERCURE_JWT_ISSUER` as the
|
|
446
|
+
token issuer and `MERCURE_PUBLIC_URL` as its audience. Browser clients
|
|
447
|
+
subscribe at `MERCURE_PUBLIC_URL`. Development allows anonymous subscriptions
|
|
448
|
+
to public updates. [Mercure token authorization](https://mercure.rocks/docs/concepts/authorization)
|
|
449
|
+
|
|
450
|
+
In `.env.production`, set `MERCURE_PUBLIC_URL` to a public HTTPS URL ending
|
|
451
|
+
in `/.well-known/mercure`, set `MERCURE_JWT_ISSUER` and
|
|
452
|
+
`MERCURE_JWT_SECRET`, and list app origins in `MERCURE_ALLOWED_ORIGINS`.
|
|
453
|
+
Production subscriptions require a token. Route the public URL to port
|
|
454
|
+
`80` on the hub and configure the reverse proxy to stream responses.
|
|
455
|
+
[Mercure reverse proxy guide](https://mercure.rocks/docs/deployment/reverse-proxy)
|
|
456
|
+
|
|
457
|
+
### Web servers: ASGI and WSGI
|
|
458
|
+
|
|
459
|
+
`ship init` offers servers that match the application interface. Ship
|
|
460
|
+
installs the selected server and enables reload in development. The server
|
|
461
|
+
binds to `0.0.0.0:8000` inside the container in both environments.
|
|
462
|
+
|
|
463
|
+
| App | Interface | Available servers |
|
|
464
|
+
|---|---|---|
|
|
465
|
+
| FastAPI, Django's `project.asgi:application`, or a plain ASGI callable | ASGI | Uvicorn (recommended), Granian, Hypercorn |
|
|
466
|
+
| Flask, Django's `project.wsgi:application`, or a plain WSGI callable | WSGI | Gunicorn (recommended), Granian |
|
|
467
|
+
|
|
468
|
+
Choose a server with `ship init --server hypercorn` or Ship's `server`
|
|
469
|
+
setting in `ship.json`. See the
|
|
470
|
+
[runtime guide](docs/standalone-runtimes.md) for copyable entry points,
|
|
471
|
+
server options, and production settings.
|
|
472
|
+
|
|
473
|
+
### Browser testing (`testing`)
|
|
474
|
+
|
|
475
|
+
| Service | Wired automatically | Still needed in the app |
|
|
476
|
+
|---|---|---|
|
|
477
|
+
| Selenium (`selenium`) | A Chromium grid with `SELENIUM_REMOTE_URL` and `APP_URL` | Install the Python `selenium` client and connect to the remote grid. |
|
|
478
|
+
| Playwright (`playwright`) | A remote browser server with `PLAYWRIGHT_WS_URL`, `PW_TEST_CONNECT_WS_ENDPOINT` and `PLAYWRIGHT_BASE_URL` | Match the Python Playwright client version to the browser image. |
|
|
479
|
+
| Cypress (`cypress`) | An on-demand container with the project mounted at `/e2e` and `CYPRESS_BASE_URL` set | Add a Cypress config and specs, then run `ship test`. |
|
|
480
|
+
|
|
481
|
+
Browser tests use the internal address `http://ship-app.test:8000` with
|
|
482
|
+
the selected testing service. Run `ship test` for Cypress. For Selenium
|
|
483
|
+
and Playwright, the same command runs pytest in the app, so declare pytest
|
|
484
|
+
and your browser client in the project's dev dependencies.
|
|
485
|
+
|
|
486
|
+
### Frontend (`frontend`)
|
|
487
|
+
|
|
488
|
+
Select Node (`node`) to run npm, pnpm or Yarn and Vite in a separate
|
|
489
|
+
development container. See [Vite HMR](#frontend-dev-server-vite-hmr) for setup
|
|
490
|
+
and the required port mapping. The Node image follows the `node` field in
|
|
491
|
+
`ship.json`. Set `nodeAssets` to build frontend assets into the production
|
|
492
|
+
image.
|
|
493
|
+
|
|
494
|
+
#### JavaScript package managers
|
|
495
|
+
|
|
496
|
+
Ship defaults to npm. A pnpm or Yarn project pins its tool in
|
|
497
|
+
`package.json` using an exact `packageManager` value and commits the matching
|
|
498
|
+
lockfile. Modern Yarn also needs `nodeLinker: node-modules` in `.yarnrc.yml`.
|
|
499
|
+
|
|
500
|
+
Run `ship package-manager pnpm@VERSION` with the exact version you want
|
|
501
|
+
to switch tools. The command asks before replacing lockfiles and reinstalling
|
|
502
|
+
dependencies. The `ship npm`, `ship pnpm` and `ship yarn` proxies check the
|
|
503
|
+
project's selection.
|
|
504
|
+
|
|
309
505
|
## Configuration (`ship.json`)
|
|
310
506
|
|
|
311
507
|
`ship init` writes this file; you rarely need to edit it by hand. Its field
|
|
@@ -355,12 +551,23 @@ names match PHP Ship's `ship.json`, so a team using both reads one format:
|
|
|
355
551
|
[Running more than one project at once](#running-more-than-one-project-at-once).
|
|
356
552
|
- `siloImage` — `"standard"` (default, omitted) or `"distroless"`. See
|
|
357
553
|
[Silo on older CPUs](#silo-on-older-cpus).
|
|
358
|
-
- `publishPorts` —
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
554
|
+
- `publishPorts` — legacy production publishing setting. Existing projects
|
|
555
|
+
without `portPublishing` keep their existing policy. New projects use
|
|
556
|
+
`portPublishing`.
|
|
557
|
+
- `portPublishing` — selects generated host ports independently for development
|
|
558
|
+
and production. It takes precedence over `publishPorts`. Use the Compose
|
|
559
|
+
service name after any rename, followed by the container port. TCP is
|
|
560
|
+
implicit. Append `/udp` or `/sctp` for those protocols. An empty list leaves
|
|
561
|
+
all endpoints internal. Development binds to `127.0.0.1`.
|
|
562
|
+
|
|
563
|
+
```json
|
|
564
|
+
"portPublishing": {"development": ["app:8000"], "production": ["app:8000"]}
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
The interactive wizard lets you choose these endpoints and their host port
|
|
568
|
+
numbers. It keeps existing choices where possible and suggests another
|
|
569
|
+
number if two selected endpoints would use the same port and protocol.
|
|
570
|
+
The host port settings go in `.env` and `.env.production`.
|
|
364
571
|
- `hostUser` — defaults to `true`. See [File ownership in dev](#file-ownership-in-dev).
|
|
365
572
|
- `deployCommands` — commands that run exactly once per deploy, **before**
|
|
366
573
|
the app starts — migrations, typically:
|
|
@@ -400,8 +607,9 @@ Processes may also use `{ "command": ..., "healthcheck": ..., "http": ... }`.
|
|
|
400
607
|
The HTTP block declares a container port, open role, optional health path and
|
|
401
608
|
public URL setting name. It becomes an endpoint in `release.json`.
|
|
402
609
|
|
|
403
|
-
Setup uses arrow-key selections, service checkboxes and Ctrl+U to go back
|
|
404
|
-
|
|
610
|
+
Setup uses arrow-key selections, service checkboxes and Ctrl+U to go back.
|
|
611
|
+
Piped input accepts service types by number or name, separated by commas.
|
|
612
|
+
`-n` never asks questions. The final preview
|
|
405
613
|
precedes writes. Scriptable flags include `--name`, repeated `--additional-service
|
|
406
614
|
GROUP=PROVIDER:NAME`, `--process NAME=COMMAND_OR_JSON`, `--network`,
|
|
407
615
|
`--deploy-command`, `--remove-instance`, `--remove-process` and `--no-network`.
|
|
@@ -413,21 +621,25 @@ Host-port collisions are handled with environment variables, not `ship.json`
|
|
|
413
621
|
|
|
414
622
|
Add the entry to `ship.json`'s `services` (e.g. `"cache": "redis"`) and run
|
|
415
623
|
`ship up` — it reads `ship.json` fresh every time. The exception is Garage,
|
|
416
|
-
which needs build files in `ship/garage/`; add that one by re-running
|
|
624
|
+
which needs build files in `docker/ship/garage/`; add that one by re-running
|
|
417
625
|
`ship init`.
|
|
418
626
|
|
|
419
|
-
Re-running `ship init` works for
|
|
420
|
-
current selection, so pressing Enter keeps it
|
|
421
|
-
|
|
422
|
-
`
|
|
423
|
-
|
|
424
|
-
|
|
627
|
+
Re-running `ship init` works for every service. Every prompt defaults to the
|
|
628
|
+
current selection, so pressing Enter keeps it. Settings such as `publishPorts`,
|
|
629
|
+
`hostUser`, `deployCommands` and `extensions` carry over from the existing
|
|
630
|
+
`ship.json`. It reads the old file leniently, so one invalid field doesn't
|
|
631
|
+
discard the rest.
|
|
632
|
+
|
|
633
|
+
Init shows a table for each environment file with its values and changes.
|
|
634
|
+
It masks credentials and custom values in the output, leaves new credential
|
|
635
|
+
placeholders blank in templates, and updates the connection settings that
|
|
636
|
+
Ship controls. It also suggests client packages missing from your dependency
|
|
637
|
+
manifest for the services you selected.
|
|
425
638
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
`ship init` and `ship config:test` warn when it differs from what's installed.
|
|
639
|
+
Re-running `ship init` keeps your `docker/ship/Dockerfile`. Use `ship init --force`
|
|
640
|
+
to replace it with the version matching the installed package. Ship records the
|
|
641
|
+
version that published the Dockerfile in `docker/ship/.ship-version`, and `ship up`,
|
|
642
|
+
`ship init` and `ship check` warn when it differs from what's installed.
|
|
431
643
|
|
|
432
644
|
### Multiple instances of a service
|
|
433
645
|
|
|
@@ -441,8 +653,12 @@ named instance:
|
|
|
441
653
|
]
|
|
442
654
|
```
|
|
443
655
|
|
|
444
|
-
`ship init`
|
|
445
|
-
|
|
656
|
+
`ship init` asks whether to add a named instance after the primary service
|
|
657
|
+
menus. You can continue there with only named instances. When you leave both
|
|
658
|
+
sets empty, choose **Use only the app** or **Choose services** to reopen the
|
|
659
|
+
picker.
|
|
660
|
+
|
|
661
|
+
`ship init` validates the instance name. When editing `ship.json`, `name` must be lowercase
|
|
446
662
|
letters, digits and underscores, starting with a letter (`analytics`,
|
|
447
663
|
`queue_2`). It becomes two things:
|
|
448
664
|
|
|
@@ -452,15 +668,19 @@ letters, digits and underscores, starting with a letter (`analytics`,
|
|
|
452
668
|
- The Compose service: `postgres-analytics`, with its own volume
|
|
453
669
|
(`postgres-analytics_data`), and `ship db analytics` opens its shell.
|
|
454
670
|
|
|
455
|
-
|
|
456
|
-
|
|
671
|
+
The built-in providers that support named instances are in `database`, `cache`,
|
|
672
|
+
`storage`, `search` and `mail`. Choose a browser driver, frontend toolchain or
|
|
673
|
+
RabbitMQ in the main picker. Extensions can also offer named instances.
|
|
457
674
|
|
|
458
675
|
### Custom service names and an external network
|
|
459
676
|
|
|
460
677
|
Every Compose service has a fixed name by default: `app`, and each selected
|
|
461
|
-
service's key (`postgres`, `redis`, ...).
|
|
462
|
-
|
|
463
|
-
`ship
|
|
678
|
+
service's key (`postgres`, `redis`, ...). On a shared Docker network, give the
|
|
679
|
+
services that need to be reachable distinct names. At **App service name** in
|
|
680
|
+
`ship init`, enter a name such as `client-app`, or press Enter to keep the current
|
|
681
|
+
name. If you select only the app, this is the only naming prompt. Each selected
|
|
682
|
+
service or named instance has its own prompt. Type the original name, such as
|
|
683
|
+
`app` or `postgres`, to restore that default. Custom names are saved to `ship.json`:
|
|
464
684
|
|
|
465
685
|
```json
|
|
466
686
|
{
|
|
@@ -469,13 +689,13 @@ but projects that share a Docker network collide on those names. Hand-edit
|
|
|
469
689
|
}
|
|
470
690
|
```
|
|
471
691
|
|
|
472
|
-
- `serviceNames` renames the app
|
|
692
|
+
- `serviceNames` renames the app, a selected service, or a named instance
|
|
693
|
+
such as `postgres-analytics`. The hostname a
|
|
473
694
|
service injects follows the rename (`DB_HOST=client-db`), as do `ship shell`
|
|
474
695
|
with no argument, `ship db`, `ship manage` and Mutagen sync. Volumes keep
|
|
475
696
|
their original names, so renaming never orphans data. Commands where you
|
|
476
697
|
type the service (`ship exec`, `ship logs`, `ship shell <service>`) take the
|
|
477
|
-
new name.
|
|
478
|
-
renamed.
|
|
698
|
+
new name.
|
|
479
699
|
- `externalNetwork` attaches the app (and every `processes` entry) to a
|
|
480
700
|
Docker network created outside Ship, next to the project's own network —
|
|
481
701
|
for reaching a database or cache that another Compose project runs. Point
|
|
@@ -504,33 +724,6 @@ the image. `ship uv sync`, `run`, `pip`, `python`, `tool` and `venv` are
|
|
|
504
724
|
refused, since their effects would vanish with the container — use `ship up`
|
|
505
725
|
to install and `ship exec app ...` to run.
|
|
506
726
|
|
|
507
|
-
## Web servers: ASGI and WSGI
|
|
508
|
-
|
|
509
|
-
Each framework adapter knows whether the app is ASGI (async) or WSGI (sync),
|
|
510
|
-
and `ship init` only offers servers that can run it, recommended first:
|
|
511
|
-
|
|
512
|
-
| App | Interface | Servers (recommended first) |
|
|
513
|
-
|---|---|---|
|
|
514
|
-
| FastAPI, Starlette-style apps | ASGI | Uvicorn, Granian, Hypercorn |
|
|
515
|
-
| Django with `project.asgi:application` | ASGI | Uvicorn, Granian, Hypercorn |
|
|
516
|
-
| Django with `project.wsgi:application` | WSGI | Gunicorn, Granian |
|
|
517
|
-
| Flask | WSGI | Gunicorn, Granian |
|
|
518
|
-
| A plain callable | detected from its signature: `async def app(scope, receive, send)` is ASGI, `def app(environ, start_response)` WSGI | as above |
|
|
519
|
-
|
|
520
|
-
Pick one with `ship init --server granian` or `"server": "granian"` in
|
|
521
|
-
`ship.json`; without one, Ship uses the recommended server. A server that
|
|
522
|
-
can't run the app (Gunicorn for FastAPI, Uvicorn for Flask) is a
|
|
523
|
-
configuration error naming the ones that can. Ship installs the selected
|
|
524
|
-
server into the image, with reload in development. Granian serves both
|
|
525
|
-
interfaces and runs with `--interface asgi` or `--interface wsgi` to match.
|
|
526
|
-
A community package can add another server (see [Extending ship](#extending-ship)).
|
|
527
|
-
|
|
528
|
-
In production, every server reads its tuning from `.env.production`:
|
|
529
|
-
Uvicorn and Gunicorn take `WEB_CONCURRENCY` (worker processes) and
|
|
530
|
-
`FORWARDED_ALLOW_IPS` (which proxies to trust for `X-Forwarded-*`; set it to
|
|
531
|
-
your proxy's address); Granian takes `GRANIAN_WORKERS` and its other
|
|
532
|
-
`GRANIAN_*` settings. Uvicorn runs with `--proxy-headers`.
|
|
533
|
-
|
|
534
727
|
## Background tasks (Celery)
|
|
535
728
|
|
|
536
729
|
Select Celery with a broker:
|
|
@@ -583,7 +776,7 @@ ship release --tag 1.2.0 # build + assemble the portable release artifact
|
|
|
583
776
|
Both build a materially different image from `ship up`'s development one:
|
|
584
777
|
|
|
585
778
|
- **No bind mount.** The code is copied into the image at build time, through
|
|
586
|
-
the `builder` → `production` stages of `ship/Dockerfile`.
|
|
779
|
+
the `builder` → `production` stages of `docker/ship/Dockerfile`.
|
|
587
780
|
- **No build tools, not root.** The production stage carries the installed
|
|
588
781
|
app and server only: no uv, no pip, and it runs as UID 10001.
|
|
589
782
|
- **Framework boot steps run at container *boot*, not build time.** Django
|
|
@@ -613,10 +806,10 @@ Ship enforces the following minimum Python versions for application images.
|
|
|
613
806
|
|
|
614
807
|
It is enforced at three points:
|
|
615
808
|
|
|
616
|
-
- **`ship init`, `ship
|
|
809
|
+
- **`ship init`, `ship check` and every command that generates a
|
|
617
810
|
Compose file** reject an end-of-life `python` branch, or a pinned patch
|
|
618
811
|
release below the floor (`"3.13.4"`).
|
|
619
|
-
- **The Dockerfile's `base` stage** runs `ship/check-python-security-floor.py`
|
|
812
|
+
- **The Dockerfile's `base` stage** runs `docker/ship/check-python-security-floor.py`
|
|
620
813
|
against the Python actually in the image, and fails the build if it is below
|
|
621
814
|
the floor. This catches a stale `python:3.13-slim` that Docker keeps reusing
|
|
622
815
|
from its local cache; the fix is in the message: `docker pull` that image.
|
|
@@ -631,7 +824,7 @@ ships a security release.
|
|
|
631
824
|
`ship init` appends required production setting names to `.env.production`
|
|
632
825
|
with empty values, preserving existing values and comments. Fill them before
|
|
633
826
|
building. It also merges development settings into `.env.example` and `.env`.
|
|
634
|
-
`ship
|
|
827
|
+
`ship check`, `build` and `release` reject missing required credentials
|
|
635
828
|
and known development defaults. The release copies the file privately unless
|
|
636
829
|
`--no-env` is requested. With no required settings, an absent file is allowed.
|
|
637
830
|
|
|
@@ -639,7 +832,7 @@ Selected services' secrets (`DB_PASSWORD`, `DB_ROOT_PASSWORD`,
|
|
|
639
832
|
`MEILISEARCH_KEY`, `AWS_SECRET_ACCESS_KEY`, `GARAGE_RPC_SECRET`,
|
|
640
833
|
`GARAGE_ADMIN_TOKEN`, each with its instance prefix where one applies) are
|
|
641
834
|
*required* in production: Compose itself refuses to start without them, and
|
|
642
|
-
`ship
|
|
835
|
+
`ship check`/`ship build`/`ship release` check before Docker is invoked
|
|
643
836
|
— reporting a missing value, or one still set to a development default such
|
|
644
837
|
as `ship`. Non-secret settings (`DB_DATABASE`, `DB_USERNAME`, `AWS_BUCKET`, ...) keep
|
|
645
838
|
their defaults unless you set them.
|
|
@@ -850,19 +1043,23 @@ Every published port has a variable, read from your shell or the project's
|
|
|
850
1043
|
| App | `APP_PORT` | `8000` |
|
|
851
1044
|
| Vite dev server | `VITE_PORT` | `5173` |
|
|
852
1045
|
| Mailpit web UI | `MAILPIT_WEB_PORT` | `8025` |
|
|
1046
|
+
| RabbitMQ management UI | `RABBITMQ_MANAGEMENT_PORT` | `15672` |
|
|
1047
|
+
| Centrifugo | `CENTRIFUGO_PORT` | `8001` |
|
|
1048
|
+
| Mercure | `MERCURE_PORT` | `8002` |
|
|
853
1049
|
| Silo console | `SILO_CONSOLE_PORT` | `9001` |
|
|
854
1050
|
|
|
855
1051
|
```sh
|
|
856
1052
|
APP_PORT=8001 VITE_PORT=5174 ship up
|
|
857
1053
|
```
|
|
858
1054
|
|
|
859
|
-
|
|
860
|
-
|
|
1055
|
+
Development bindings use `127.0.0.1`. In new production configurations,
|
|
1056
|
+
Ship publishes the app on `${APP_PORT:-8000}`. Set `portPublishing.production`
|
|
1057
|
+
to `[]` when the app should be reachable only from the Docker network.
|
|
861
1058
|
|
|
862
1059
|
## Customizing the stack
|
|
863
1060
|
|
|
864
|
-
`ship/docker-compose.generated.yml`
|
|
865
|
-
|
|
1061
|
+
Ship generates `docker/ship/docker-compose.generated.yml` from `ship.json`.
|
|
1062
|
+
Add your changes in a `docker-compose.override.yml`
|
|
866
1063
|
(`compose.override.yaml` works too) at the project root instead — Compose's
|
|
867
1064
|
own [merge rules](https://docs.docker.com/compose/how-tos/multiple-compose-files/merge/)
|
|
868
1065
|
apply, and every development command picks it up:
|
|
@@ -878,7 +1075,7 @@ services:
|
|
|
878
1075
|
|
|
879
1076
|
Key overrides by the *renamed* service when you use `serviceNames`. The
|
|
880
1077
|
override never applies to `ship build`/`ship release`. For the image itself,
|
|
881
|
-
edit `ship/Dockerfile` directly — `ship init` keeps your edits unless you pass
|
|
1078
|
+
edit `docker/ship/Dockerfile` directly — `ship init` keeps your edits unless you pass
|
|
882
1079
|
`--force`.
|
|
883
1080
|
|
|
884
1081
|
## Extending ship
|
|
@@ -912,6 +1109,10 @@ extension is a configuration error naming the extension. The contracts —
|
|
|
912
1109
|
`ServiceDefinition`, `FrameworkAdapter`, `WebServer`, and the optional
|
|
913
1110
|
`ProvidesDatabaseShell`/`ValidatesConfiguration`/`DescribesRelease`/`SuggestsProcesses`/`ExposesHttp` — are typed protocols in
|
|
914
1111
|
[`python_ship.contracts`](https://github.com/ship-ecosystem/python-ship/blob/main/src/python_ship/contracts.py).
|
|
1112
|
+
Framework adapters can supply service providers through `services()`, env-file
|
|
1113
|
+
defaults through `environment_defaults(config, root, environment)`, and setup
|
|
1114
|
+
instructions through `setup_advice(config, root)`. Setup advice uses `SetupAdvice`
|
|
1115
|
+
entries. Set `before_up=True` to show an instruction again at startup.
|
|
915
1116
|
See [`docs/adding-a-service.md`](https://github.com/ship-ecosystem/python-ship/blob/main/docs/adding-a-service.md)
|
|
916
1117
|
for a worked example, and the installable
|
|
917
1118
|
[service](https://github.com/ship-ecosystem/python-ship/tree/main/examples/community-service) and
|