reflex/docker-example/simple-one-port
Masen Furer 0a34949019
Add production-one-port example (#4489)
* Add production-one-port example

A more complex version of simple-one-port that facilitates better layer caching
to shorten build times and multi-stage build to reduce final image size.

Harder to understand, but ultimately nicer to use.

* fix Caddyfile format to avoid complaints

* docker-examples: bump all base images to python:3.13
2024-12-09 15:26:48 -08:00
..
.dockerignore Update docker-example (#3324) 2024-09-08 19:21:05 -07:00
Caddyfile Add production-one-port example (#4489) 2024-12-09 15:26:48 -08:00
Dockerfile Add production-one-port example (#4489) 2024-12-09 15:26:48 -08:00
README.md Update docker-example (#3324) 2024-09-08 19:21:05 -07:00

simple-one-port

This docker deployment runs Reflex in prod mode, exposing a single HTTP port:

  • 8080 ($PORT) - Caddy server hosting the frontend statically and proxying requests to the backend.

The deployment also runs a local Redis server to store state for each user.

Using this method may be preferable for deploying in memory constrained environments, because it serves a static frontend export, rather than running the NextJS server via node.

For platforms which only terminate TLS to a single port, this container can be deployed instead of the simple-two-port example.

Build

docker build -t reflex-simple-one-port .

Run

docker run -p 8080:8080 reflex-simple-one-port

Note that this container has no persistence and will lose all data when stopped. You can use bind mounts or named volumes to persist the database and uploaded_files directories as needed.

Usage

This container should be used with an existing load balancer or reverse proxy to terminate TLS.

It is also useful for deploying to simple app platforms, such as Render or Heroku.