derek-thomas's picture
Using 2-port build
16552c4 verified
raw
history blame
1.11 kB
# This Dockerfile is used to deploy a simple single-container Reflex app instance.
FROM python:3.13
# Install Redis and other system dependencies
RUN apt-get update && apt-get install -y redis-server && rm -rf /var/lib/apt/lists/*
ENV REDIS_URL=redis://localhost PYTHONUNBUFFERED=1
# Create a non-root user for security
RUN useradd -m -u 1000 user
# Set the working directory
WORKDIR /app
# Copy local context to `/app` inside container (see .dockerignore)
COPY . .
# Set ownership of the application directory to the non-root user
RUN chown -R user:user /app
# Switch to the non-root user
USER user
# Install app requirements and reflex in the container
RUN pip install --no-cache-dir -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