diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f155d25 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.12 + + +ENV REDIS_URL=redis://redis PYTHONUNBUFFERED=1 + +WORKDIR /app +COPY . . + +RUN pip install -r requirements.txt + + +ENTRYPOINT ["reflex", "run", "--env", "prod", "--backend-only", "--loglevel", "debug" ] diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..aa2d6fe --- /dev/null +++ b/compose.yml @@ -0,0 +1,18 @@ +services: + backend: + build: + dockerfile: Dockerfile + ports: + - 8000:8000 + depends_on: + - redis + frontend: + build: + dockerfile: web.Dockerfile + ports: + - 3000:80 + depends_on: + - backend + redis: + image: redis + diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..6647366 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,33 @@ +server { + listen 80; + listen [::]:80; + server_name frontend; + + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location /_event { + proxy_set_header Connection "upgrade"; + proxy_pass http://backend:8000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + } + + location /ping { + proxy_pass http://backend:8000; + } + + location /_upload { + proxy_pass http://backend:8000; + } + + location / { + # This would be the directory where your Reflex app's static files are stored at + root /usr/share/nginx/html; + try_files $uri /$uri/index.html; + } + +} diff --git a/web.Dockerfile b/web.Dockerfile new file mode 100644 index 0000000..c5fcbbb --- /dev/null +++ b/web.Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.12 AS builder + +WORKDIR /app + +COPY . . +RUN pip install -r requirements.txt +RUN reflex export --frontend-only --no-zip + +FROM nginx + +COPY --from=builder /app/.web/_static /usr/share/nginx/html +COPY ./nginx.conf /etc/nginx/conf.d/default.conf