Skip to main content

enlace_docker

Docker / docker-compose backend strategies for enlace.

Installing this package adds four new mode values to app.toml:

Mode What enlace does
docker Build the app's Dockerfile, run the container, supervise, route HTTP to it
image Pull a pre-built image, run it, supervise, route HTTP to it (no build step)
compose docker compose up -d the app's stack, route HTTP to a declared service+port, down on shutdown
docker_attached Route HTTP to an already-running container by name (no lifecycle management)

No code change in enlace is needed — enlace_docker registers via the enlace.backend_strategies entry-point group. Installing the package is enough.

Status

Scope: dev orchestration only. Production runs docker compose up out of band; enlace routes to it via the built-in mode=external. This package covers enlace serve / enlace dev. See enlace#3 for the design.

Install

pip install enlace_docker

Requires the docker CLI on PATH. Compose support requires docker compose (the v2 plugin, not the legacy docker-compose).

Usage

Network exposure

Containers enlace starts (docker, image modes) publish their port on the host's loopback interface only (127.0.0.1:<port>:<port>), so they are reachable solely through the enlace gateway, where auth is applied. For compose and docker_attached, the port mapping is yours: enlace logs a warning when the routed port is published on a non-loopback address — publish it as "127.0.0.1::<port>" (compose) or -p 127.0.0.1:<port>:<port> (docker run). Note that on Docker Engine < 28, hosts on the same L2 network could still reach loopback-published ports (moby/moby#45610).

Platform credentials

Every mode proxies with the same filters as enlace's mode="process": the container does not see the visitor's platform cookies (enlace_session, enlace_csrf, enlace_oauth_state, shared_auth_*, and a custom [auth] session_cookie_name) or the X-CSRF-Token header, and it can never set a platform cookie or send Clear-Site-Data / Service-Worker-Allowed on the platform's origin. An app that genuinely needs the caller's session can opt in to receiving those credentials (never to setting them):

forward_platform_credentials = true

Dockerfile-per-app

# apps/myapp/app.toml
mode = "docker"
port = 8080            # in-container port to expose
dockerfile = "Dockerfile"   # default
context = "."               # default
build_args = { ENV = "dev" }
env = { LOG_LEVEL = "info" }

Pre-built image

mode = "image"
image = "ghcr.io/myorg/myapp:1.2.3"
port = 8080
env = { LOG_LEVEL = "info" }

docker-compose

mode = "compose"
compose_file = "docker-compose.yml"   # default
service = "web"                       # which service receives HTTP
port = 8080                           # service's internal port

Already-running container

mode = "docker_attached"
container = "my-running-container"
port = 8080

How it works

Each mode registers a BackendStrategy against enlace's open/closed extension point. The strategy provides:

  • a TOML field overlay so app.toml carries docker-specific config;
  • a make_asgi that proxies HTTP to the container's published host port;
  • a make_lifecycle (for the supervisable modes) that shells out to docker / docker compose for start, stop, health, and log streaming.

License

Apache-2.0.

Metadata

Release files for enlace_docker 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enlace_docker 0.0.7
File Size Uploaded
enlace_docker-0.0.7.tar.gz 33.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for enlace_docker 0.0.7
File Interpreter ABI Platform
enlace_docker-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 73.9 kB

Release files / enlace_docker-0.0.7.tar.gz

Download URL enlace_docker-0.0.7.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b3d2f1a1cd55f8180358dcf7a9a4a2c83584fda074d0533ab668d9059e82cde4
BLAKE2b-256 checksum
How to use checksums
19a8becdfdec49cc1eae820d1ca9b8111d31b67d6eb4b46ee51ede1cbdf25d07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / enlace_docker-0.0.7-py3-none-any.whl

Download URL enlace_docker-0.0.7-py3-none-any.whl
Size 40.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
193a5a1e3d3a964ba0cd83c04fdf2d8629470025e9594c733460859a7aa4d2cc
BLAKE2b-256 checksum
How to use checksums
e67b31fe56d71783439c97a03578eae6bd7c17a711340daa6fe35b2112198a00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page