Skip to content

Commit de50050

Browse files
committed
Merge branch 'main' into lendemor/support_python_3_13
2 parents 65fe824 + 2ee201b commit de50050

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1313
-690
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Enhancement Request
3+
about: Suggest an enhancement for an existing Reflex feature.
4+
title: ''
5+
labels: 'enhancement'
6+
assignees: ''
7+
---
8+
9+
**Describe the Enhancement you want**
10+
A clear and concise description of what the improvement does.
11+
12+
- Which feature do you want to improve? (and what problem does it have)
13+
14+
- What is the benefit of the enhancement?
15+
16+
- Show an example/usecase were the improvement are needed.
17+
18+
**Additional context**
19+
Add any other context here.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature for Reflex
4+
title: ''
5+
labels: 'feature request'
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the Features**
11+
A clear and concise description of what the features does.
12+
13+
- What is the purpose of the feature?
14+
15+
- Show an example / use cases for the new feature.
16+
17+
**Additional context**
18+
Add any other context here.

.github/workflows/integration_tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,36 @@ jobs:
162162
--python-version "${{ matrix.python-version }}" --commit-sha "${{ github.sha }}"
163163
--pr-id "${{ github.event.pull_request.id }}" --branch-name "${{ github.head_ref || github.ref_name }}"
164164
--app-name "reflex-web" --path ./reflex-web/.web
165+
166+
rx-shout-from-template:
167+
strategy:
168+
fail-fast: false
169+
runs-on: ubuntu-latest
170+
steps:
171+
- uses: actions/checkout@v4
172+
- uses: ./.github/actions/setup_build_env
173+
with:
174+
python-version: '3.11.4'
175+
run-poetry-install: true
176+
create-venv-at-path: .venv
177+
- name: Create app directory
178+
run: mkdir rx-shout-from-template
179+
- name: Init reflex-web from template
180+
run: poetry run reflex init --template https://github.com/masenf/rx_shout
181+
working-directory: ./rx-shout-from-template
182+
- name: ignore reflex pin in requirements
183+
run: sed -i -e '/reflex==/d' requirements.txt
184+
working-directory: ./rx-shout-from-template
185+
- name: Install additional dependencies
186+
run: poetry run uv pip install -r requirements.txt
187+
working-directory: ./rx-shout-from-template
188+
- name: Run Website and Check for errors
189+
run: |
190+
# Check that npm is home
191+
npm -v
192+
poetry run bash scripts/integration.sh ./rx-shout-from-template prod
165193
194+
166195
reflex-web-macos:
167196
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
168197
strategy:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fail_fast: true
33
repos:
44

55
- repo: https://github.com/charliermarsh/ruff-pre-commit
6-
rev: v0.7.4
6+
rev: v0.8.2
77
hooks:
88
- id: ruff-format
99
args: [reflex, tests]

docker-example/production-app-platform/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# for example, pass `docker build --platform=linux/amd64 ...`
2424

2525
# Stage 1: init
26-
FROM python:3.11 as init
26+
FROM python:3.13 as init
2727

2828
ARG uv=/root/.local/bin/uv
2929

@@ -48,7 +48,7 @@ RUN $uv pip install -r requirements.txt
4848
RUN reflex init
4949

5050
# Stage 2: copy artifacts into slim image
51-
FROM python:3.11-slim
51+
FROM python:3.13-slim
5252
WORKDIR /app
5353
RUN adduser --disabled-password --home /app reflex
5454
COPY --chown=reflex --from=init /app /app

docker-example/production-compose/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# instance of a Reflex app.
33

44
# Stage 1: init
5-
FROM python:3.11 as init
5+
FROM python:3.13 as init
66

77
ARG uv=/root/.local/bin/uv
88

@@ -35,7 +35,7 @@ RUN rm -rf .web && mkdir .web
3535
RUN mv /tmp/_static .web/_static
3636

3737
# Stage 2: copy artifacts into slim image
38-
FROM python:3.11-slim
38+
FROM python:3.13-slim
3939
WORKDIR /app
4040
RUN adduser --disabled-password --home /app reflex
4141
COPY --chown=reflex --from=init /app /app
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.web
2+
!.web/bun.lockb
3+
!.web/package.json
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
:{$PORT}
2+
3+
encode gzip
4+
5+
@backend_routes path /_event/* /ping /_upload /_upload/*
6+
handle @backend_routes {
7+
reverse_proxy localhost:8000
8+
}
9+
10+
root * /srv
11+
route {
12+
try_files {path} {path}/ /404.html
13+
file_server
14+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This Dockerfile is used to deploy a single-container Reflex app instance
2+
# to services like Render, Railway, Heroku, GCP, and others.
3+
4+
# If the service expects a different port, provide it here (f.e Render expects port 10000)
5+
ARG PORT=8080
6+
# Only set for local/direct access. When TLS is used, the API_URL is assumed to be the same as the frontend.
7+
ARG API_URL
8+
9+
# It uses a reverse proxy to serve the frontend statically and proxy to backend
10+
# from a single exposed port, expecting TLS termination to be handled at the
11+
# edge by the given platform.
12+
FROM python:3.13 as builder
13+
14+
RUN mkdir -p /app/.web
15+
RUN python -m venv /app/.venv
16+
ENV PATH="/app/.venv/bin:$PATH"
17+
18+
WORKDIR /app
19+
20+
# Install python app requirements and reflex in the container
21+
COPY requirements.txt .
22+
RUN pip install -r requirements.txt
23+
24+
# Install reflex helper utilities like bun/fnm/node
25+
COPY rxconfig.py ./
26+
RUN reflex init
27+
28+
# Install pre-cached frontend dependencies (if exist)
29+
COPY *.web/bun.lockb *.web/package.json .web/
30+
RUN if [ -f .web/bun.lockb ]; then cd .web && ~/.local/share/reflex/bun/bin/bun install --frozen-lockfile; fi
31+
32+
# Copy local context to `/app` inside container (see .dockerignore)
33+
COPY . .
34+
35+
ARG PORT API_URL
36+
# Download other npm dependencies and compile frontend
37+
RUN API_URL=${API_URL:-http://localhost:$PORT} reflex export --loglevel debug --frontend-only --no-zip && mv .web/_static/* /srv/ && rm -rf .web
38+
39+
40+
# Final image with only necessary files
41+
FROM python:3.13-slim
42+
43+
# Install Caddy and redis server inside image
44+
RUN apt-get update -y && apt-get install -y caddy redis-server && rm -rf /var/lib/apt/lists/*
45+
46+
ARG PORT API_URL
47+
ENV PATH="/app/.venv/bin:$PATH" PORT=$PORT API_URL=${API_URL:-http://localhost:$PORT} REDIS_URL=redis://localhost PYTHONUNBUFFERED=1
48+
49+
WORKDIR /app
50+
COPY --from=builder /app /app
51+
COPY --from=builder /srv /srv
52+
53+
# Needed until Reflex properly passes SIGTERM on backend.
54+
STOPSIGNAL SIGKILL
55+
56+
EXPOSE $PORT
57+
58+
# Apply migrations before starting the backend.
59+
CMD [ -d alembic ] && reflex db migrate; \
60+
caddy start && \
61+
redis-server --daemonize yes && \
62+
exec reflex run --env prod --backend-only
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# production-one-port
2+
3+
This docker deployment runs Reflex in prod mode, exposing a single HTTP port:
4+
* `8080` (`$PORT`) - Caddy server hosting the frontend statically and proxying requests to the backend.
5+
6+
The deployment also runs a local Redis server to store state for each user.
7+
8+
Conceptually it is similar to the `simple-one-port` example except it:
9+
* has layer caching for python, reflex, and node dependencies
10+
* uses multi-stage build to reduce the size of the final image
11+
12+
Using this method may be preferable for deploying in memory constrained
13+
environments, because it serves a static frontend export, rather than running
14+
the NextJS server via node.
15+
16+
## Build
17+
18+
```console
19+
docker build -t reflex-production-one-port .
20+
```
21+
22+
## Run
23+
24+
```console
25+
docker run -p 8080:8080 reflex-production-one-port
26+
```
27+
28+
Note that this container has _no persistence_ and will lose all data when
29+
stopped. You can use bind mounts or named volumes to persist the database and
30+
uploaded_files directories as needed.
31+
32+
## Usage
33+
34+
This container should be used with an existing load balancer or reverse proxy to
35+
terminate TLS.
36+
37+
It is also useful for deploying to simple app platforms, such as Render or Heroku.

docker-example/simple-one-port/Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ root * /srv
1111
route {
1212
try_files {path} {path}/ /404.html
1313
file_server
14-
}
14+
}

docker-example/simple-one-port/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# It uses a reverse proxy to serve the frontend statically and proxy to backend
55
# from a single exposed port, expecting TLS termination to be handled at the
66
# edge by the given platform.
7-
FROM python:3.11
7+
FROM python:3.13
88

99
# If the service expects a different port, provide it here (f.e Render expects port 10000)
1010
ARG PORT=8080
@@ -38,4 +38,4 @@ EXPOSE $PORT
3838
CMD [ -d alembic ] && reflex db migrate; \
3939
caddy start && \
4040
redis-server --daemonize yes && \
41-
exec reflex run --env prod --backend-only
41+
exec reflex run --env prod --backend-only

docker-example/simple-two-port/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This Dockerfile is used to deploy a simple single-container Reflex app instance.
2-
FROM python:3.12
2+
FROM python:3.13
33

44
RUN apt-get update && apt-get install -y redis-server && rm -rf /var/lib/apt/lists/*
55
ENV REDIS_URL=redis://localhost PYTHONUNBUFFERED=1

0 commit comments

Comments
 (0)