-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jakepenzak
committed
Jun 17, 2024
1 parent
ed8ffc4
commit 34a19bc
Showing
8 changed files
with
126 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
.web | ||
__pycache__/* | ||
.git | ||
__pycache__/* | ||
Dockerfile | ||
Caddy.Dockerfile | ||
compose.yaml | ||
compose.*.yaml | ||
uploaded_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use this override file to run the app in prod mode with postgres and redis | ||
# docker compose -f compose.yaml -f compose.prod.yaml up -d | ||
services: | ||
db: | ||
image: postgres | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: secret | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
|
||
redis: | ||
image: redis | ||
restart: always | ||
|
||
app: | ||
environment: | ||
DB_URL: postgresql+psycopg2://postgres:secret@db/postgres | ||
REDIS_URL: redis://redis:6379 | ||
depends_on: | ||
- db | ||
- redis | ||
|
||
volumes: | ||
postgres-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Use this override file with `compose.prod.yaml` to run admin tools | ||
# for production services. | ||
# docker compose -f compose.yaml -f compose.prod.yaml -f compose.tools.yaml up -d | ||
services: | ||
adminer: | ||
image: adminer | ||
ports: | ||
- 8080:8080 | ||
|
||
redis-commander: | ||
image: ghcr.io/joeferner/redis-commander:latest | ||
environment: | ||
- REDIS_HOSTS=local:redis:6379 | ||
ports: | ||
- "8081:8081" | ||
|
||
volumes: | ||
redis-ui-settings: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# This docker file is intended to be used with docker compose to deploy a production | ||
# instance of a Reflex app. | ||
|
||
# Stage 1: init | ||
FROM python:3.11 as init | ||
|
||
ARG uv=/root/.cargo/bin/uv | ||
|
||
# Install `uv` for faster package boostrapping | ||
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh | ||
RUN /install.sh && rm /install.sh | ||
|
||
# Copy local context to `/app` inside container (see .dockerignore) | ||
WORKDIR /app | ||
COPY . . | ||
RUN mkdir -p /app/data /app/uploaded_files | ||
|
||
# Create virtualenv which will be copied into final container | ||
ENV VIRTUAL_ENV=/app/.venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
RUN $uv venv | ||
|
||
# Install app requirements and reflex inside virtualenv | ||
RUN $uv pip install -r env/requirements.txt -r env/reflex_requirements.txt | ||
|
||
# Deploy templates and prepare app | ||
RUN reflex init | ||
|
||
# Export static copy of frontend to /app/.web/_static | ||
RUN reflex export --frontend-only --no-zip | ||
|
||
# Copy static files out of /app to save space in backend image | ||
RUN mv .web/_static /tmp/_static | ||
RUN rm -rf .web && mkdir .web | ||
RUN mv /tmp/_static .web/_static | ||
|
||
# Stage 2: copy artifacts into slim image | ||
FROM python:3.11-slim | ||
WORKDIR /app | ||
RUN adduser --disabled-password --home /app reflex | ||
COPY --chown=reflex --from=init /app /app | ||
# Install libpq-dev for psycopg2 (skip if not using postgres). | ||
RUN apt-get update -y && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* | ||
USER reflex | ||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
# Needed until Reflex properly passes SIGTERM on backend. | ||
STOPSIGNAL SIGKILL | ||
|
||
# Always apply migrations before starting the backend. | ||
CMD reflex db migrate && reflex run --env prod --backend-only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reflex==0.5.4 |