mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 11:03:50 +00:00
Reverse proxy works locally :D
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
{
|
timmypidashev.localhost {
|
||||||
auto_https off
|
encode gzip
|
||||||
}
|
|
||||||
|
|
||||||
127.0.0.1:80 {
|
reverse_proxy landing:3000
|
||||||
@backend_routes {
|
|
||||||
|
@backend_routes {
|
||||||
path /_event/*
|
path /_event/*
|
||||||
path /_upload
|
path /_upload
|
||||||
path /ping
|
path /ping
|
||||||
}
|
}
|
||||||
|
|
||||||
handle @backend_routes {
|
handle @backend_routes {
|
||||||
reverse_proxy landing:3000
|
reverse_proxy landing:8000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
proxy:
|
caddy:
|
||||||
container_name: proxy
|
container_name: caddy
|
||||||
image: caddy:latest
|
image: caddy:latest
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
|
- 443:443
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile.dev:/etc/caddy/Caddyfile:rw
|
- ./Caddyfile.dev:/etc/caddy/Caddyfile:rw
|
||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- external
|
- caddy
|
||||||
depends_on:
|
depends_on:
|
||||||
- landing
|
- landing
|
||||||
|
|
||||||
@@ -18,14 +19,13 @@ services:
|
|||||||
container_name: landing
|
container_name: landing
|
||||||
image: landing:dev
|
image: landing:dev
|
||||||
volumes:
|
volumes:
|
||||||
- ./src/landing:/app
|
- ./src/landing/landing:/app/landing
|
||||||
expose:
|
- ./src/landing/assets:/app/assets
|
||||||
- 3000
|
- ./src/landing/rxconfig.py:/app/rxconfig.py
|
||||||
- 8000
|
|
||||||
networks:
|
networks:
|
||||||
- external
|
- caddy
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
external:
|
caddy:
|
||||||
name: external
|
name: caddy
|
||||||
driver: bridge
|
external: true
|
||||||
|
|||||||
@@ -1,17 +1,54 @@
|
|||||||
FROM python:3.11
|
# Stage 1: init
|
||||||
|
FROM python:3.11 as init
|
||||||
|
|
||||||
# Copy local context to `/app` inside container (see .dockerignore)
|
# Copy local context to `/app` inside container (see .dockerignore)
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Install app requirements and reflex in the container
|
# Create virtualenv which will be copied into the final container
|
||||||
|
ENV VIRTUAL_ENV=/app/.venv
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
RUN python3.11 -m venv $VIRTUAL_ENV
|
||||||
|
|
||||||
|
# Install app requirements and reflex inside virtualenv
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
# Deploy templates and prepare app
|
# Deploy templates and prepare app
|
||||||
RUN reflex init
|
RUN reflex init
|
||||||
|
|
||||||
# Needed until Reflex properly passes SIGTERM on backend.
|
# Export static copy of frontend to /app/.web/_static
|
||||||
STOPSIGNAL SIGKILL
|
RUN echo "Exporting reflex app to shrink the docker image size, not actually a prod build."
|
||||||
|
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
|
||||||
|
|
||||||
|
# Install Node.js and unzip
|
||||||
|
RUN apt-get update && apt-get install -y nodejs unzip curl && curl -fsSL https://bun.sh/install | bash
|
||||||
|
|
||||||
|
# Copy only the necessary files from the "init" stage
|
||||||
|
COPY --chown=reflex --from=init /app/.venv /app/.venv
|
||||||
|
COPY --chown=reflex --from=init /app/requirements.txt /app/requirements.txt
|
||||||
|
COPY --chown=reflex --from=init /app /app
|
||||||
|
|
||||||
|
# Change the ownership and permissions of /app/.local
|
||||||
|
USER root
|
||||||
|
RUN mkdir -p /app
|
||||||
|
RUN chown -R reflex /app
|
||||||
|
USER reflex
|
||||||
|
|
||||||
|
# Activate the virtual environment and install application requirements
|
||||||
|
ENV PATH="/app/.venv/bin:$PATH"
|
||||||
|
RUN python3.11 -m venv /app/.venv
|
||||||
|
RUN /app/.venv/bin/pip install -r /app/requirements.txt
|
||||||
|
|
||||||
|
# The following lines are for the specific command for the application.
|
||||||
|
CMD reflex init && reflex run --env dev
|
||||||
|
|
||||||
# Always apply migrations before starting the backend.
|
|
||||||
CMD reflex run --env dev
|
|
||||||
|
|||||||
@@ -2,4 +2,5 @@ import reflex as rx
|
|||||||
|
|
||||||
config = rx.Config(
|
config = rx.Config(
|
||||||
app_name="landing",
|
app_name="landing",
|
||||||
|
api_url="http://localhost:8000",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user