reflex/docker-example/simple-two-port/Dockerfile
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

27 lines
815 B
Docker

# This Dockerfile is used to deploy a simple single-container Reflex app instance.
FROM python:3.13
RUN apt-get update && apt-get install -y redis-server && rm -rf /var/lib/apt/lists/*
ENV REDIS_URL=redis://localhost PYTHONUNBUFFERED=1
# Copy local context to `/app` inside container (see .dockerignore)
WORKDIR /app
COPY . .
# Install app requirements and reflex in the container
RUN pip install -r requirements.txt
# Deploy templates and prepare app
RUN reflex init
# Download all npm dependencies and compile frontend
RUN reflex export --frontend-only --no-zip
# Needed until Reflex properly passes SIGTERM on backend.
STOPSIGNAL SIGKILL
# Always apply migrations before starting the backend.
CMD [ -d alembic ] && reflex db migrate; \
redis-server --daemonize yes && \
exec reflex run --env prod