From 9204d1c5693c3d147c68ecb51f8eb36bcb342710 Mon Sep 17 00:00:00 2001 From: Timothy Pidashev Date: Wed, 6 Mar 2024 14:55:36 -0800 Subject: [PATCH] proxy updates --- .gitattributes | 4 ---- Caddyfile.dev | 5 +++++ Makefile | 13 ++---------- compose.dev.yml | 24 ++++++---------------- src/landing/.dockerignore | 3 +++ src/landing/.gitignore | 4 ++++ src/landing/Dockerfile.dev | 20 ++++++++++++++++++ src/landing/assets/favicon.ico | Bin 0 -> 4286 bytes src/landing/landing/__init__.py | 0 src/landing/landing/landing.py | 35 ++++++++++++++++++++++++++++++++ src/landing/requirements.txt | 1 + src/landing/rxconfig.py | 5 +++++ 12 files changed, 81 insertions(+), 33 deletions(-) delete mode 100644 .gitattributes create mode 100644 Caddyfile.dev create mode 100644 src/landing/.dockerignore create mode 100644 src/landing/.gitignore create mode 100644 src/landing/Dockerfile.dev create mode 100644 src/landing/assets/favicon.ico create mode 100644 src/landing/landing/__init__.py create mode 100644 src/landing/landing/landing.py create mode 100644 src/landing/requirements.txt create mode 100644 src/landing/rxconfig.py diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index d9a2449..0000000 --- a/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -# See https://git-scm.com/docs/gitattributes for more about git attribute files. - -# Mark any vendored files as having been vendored. -vendor/* linguist-vendored diff --git a/Caddyfile.dev b/Caddyfile.dev new file mode 100644 index 0000000..c500c4e --- /dev/null +++ b/Caddyfile.dev @@ -0,0 +1,5 @@ +localhost + +encode gzip + +reverse_proxy landing:3000 diff --git a/Makefile b/Makefile index 9340ad4..2dcee74 100644 --- a/Makefile +++ b/Makefile @@ -6,21 +6,11 @@ PROJECT_SOURCES := "https://github.com/timmypidashev/web" PROJECT_REGISTRY := "ghcr.io/timmypidashev/web" PROJECT_ORGANIZATION := "org.opencontainers" -CONTAINER_PROXY_NAME := "proxy" -CONTAINER_PROXY_VERSION := "v0.0.1" -CONTAINER_PROXY_LOCATION := "src/proxy" -CONTAINER_PROXY_DESCRIPTION := "A Caddy reverse proxy." - CONTAINER_LANDING_NAME := "landing" CONTAINER_LANDING_VERSION := "v1.0.0" -CONTAINER_LANDING_LOCATION := "src/web/landing" +CONTAINER_LANDING_LOCATION := "src/landing" CONTAINER_LANDING_DESCRIPTION := "The landing page for my website." -CONTAINER_BLOG_NAME := "blog" -CONTAINER_BLOG_VERSION := "v0.0.0" -CONTAINER_BLOG_LOCATION := "src/web/blog" -CONTAINER_BLOG_DESCRIPTION := "The blog page for my website." - .DEFAULT_GOAL := help .PHONY: run build push prune bump .SILENT: run build push prune bump @@ -53,6 +43,7 @@ run: docker compose -f compose.$(word 2,$(MAKECMDGOALS)).yml up --remove-orphans + build: # Arguments # [container]: Build context(which container to build ['all' to build every container defined]) diff --git a/compose.dev.yml b/compose.dev.yml index f23eed6..cafeddf 100644 --- a/compose.dev.yml +++ b/compose.dev.yml @@ -3,15 +3,12 @@ version: "3.8" services: proxy: container_name: proxy - build: - context: ./src/proxy - dockerfile: Dockerfile.dev + image: caddy:latest ports: - - "80:80" - - "443:443" + - 80:80 + - 443:443 volumes: - - "./src/proxy/Caddyfile.dev:/Caddyfile.dev:ro" - - "./src/proxy/certs:/certs:rw" + - ./Caddyfile.dev:/etc/caddy/Caddyfile:ro restart: always networks: - proxy @@ -20,20 +17,11 @@ services: landing: container_name: landing - build: - context: ./src/landing - dockerfile: Dockerfile.dev - ports: - - "3000:3000" - - "8000:8000" - volumes: - - "./src/landing:/landing:rw" + image: landing:dev networks: - proxy - - networks: - # The proxy network is the only network exposed externally proxy: name: proxy + driver: bridge diff --git a/src/landing/.dockerignore b/src/landing/.dockerignore new file mode 100644 index 0000000..b289110 --- /dev/null +++ b/src/landing/.dockerignore @@ -0,0 +1,3 @@ +.web +__pycache__/* +Dockerfile diff --git a/src/landing/.gitignore b/src/landing/.gitignore new file mode 100644 index 0000000..eab0d4b --- /dev/null +++ b/src/landing/.gitignore @@ -0,0 +1,4 @@ +*.db +*.py[cod] +.web +__pycache__/ \ No newline at end of file diff --git a/src/landing/Dockerfile.dev b/src/landing/Dockerfile.dev new file mode 100644 index 0000000..c67d0ad --- /dev/null +++ b/src/landing/Dockerfile.dev @@ -0,0 +1,20 @@ +FROM python:3.11 + +# Copy local context to `/app` inside container (see .dockerignore) +WORKDIR /app +COPY . . + +# Install app requirements and reflex in the container +RUN pip install -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 reflex run --env dev diff --git a/src/landing/assets/favicon.ico b/src/landing/assets/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..166ae995eaa63fc96771410a758282dc30e925cf GIT binary patch literal 4286 zcmeHL>rYc>81ELdEe;}zmYd}cUgmJRfwjUwD1`#s5KZP>mMqza#Viv|_7|8f+0+bX zHuqusuw-7Ca`DTu#4U4^o2bjO#K>4%N?Wdi*wZ3Vx%~Ef4}D1`U_EMRg3u z#2#M|V>}}q-@IaO@{9R}d*u7f&~5HfxSkmHVcazU#i30H zAGxQ5Spe!j9`KuGqR@aExK`-}sH1jvqoIp3C7Vm)9Tu=UPE;j^esN~a6^a$ZILngo;^ zGLXl(ZFyY&U!li`6}y-hUQ99v?s`U4O!kgog74FPw-9g+V)qs!jFGEQyvBf><U|E2vRmx|+(VI~S=lT?@~C5pvZOd`x{Q_+3tG6H=gtdWcf z)+7-Zp=UqH^J4sk^>_G-Ufn-2Hz z2mN12|C{5}U`^eCQuFz=F%wp@}SzA1MHEaM^CtJs<{}Tzu$bx2orTKiedgmtVGM{ zdd#vX`&cuiec|My_KW;y{Ryz2kFu9}=~us6hvx1ZqQCk(d+>HP>ks>mmHCjjDh{pe zKQkKpk0SeDX#XMqf$}QV{z=xrN!mQczJAvud@;zFqaU1ocq==Py)qsa=8UKrt!J7r z{RsTo^rgtZo%$rak)DN*D)!(Y^$@yL6Nd=#eu&?unzhH8yq>v{gkt8xcG3S%H)-y_ zqQ1|v|JT$0R~Y}omg2Y+nDvR+K|kzR5i^fmKF>j~N;A35Vr`JWh4yRqKl#P|qlx?` z@|CmBiP}ysYO%m2{eBG6&ix5 zr#u((F2{vb=W4jNmTQh3M^F2o80T49?w>*rv0mt)-o1y!{hRk`E#UVPdna6jnz`rw dKpn)r^--YJZpr;bYU`N~>#v3X5BRU&{{=gv-{1fM literal 0 HcmV?d00001 diff --git a/src/landing/landing/__init__.py b/src/landing/landing/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/landing/landing/landing.py b/src/landing/landing/landing.py new file mode 100644 index 0000000..4a17519 --- /dev/null +++ b/src/landing/landing/landing.py @@ -0,0 +1,35 @@ +"""Welcome to Reflex! This file outlines the steps to create a basic app.""" + +from rxconfig import config + +import reflex as rx + +docs_url = "https://reflex.dev/docs/getting-started/introduction" +filename = f"{config.app_name}/{config.app_name}.py" + + +class State(rx.State): + """The app state.""" + + +def index() -> rx.Component: + return rx.center( + rx.theme_panel(), + rx.vstack( + rx.heading("Welcome to Reflex!", size="9"), + rx.text("Get started by editing ", rx.code(filename)), + rx.button( + "Check out our docs!", + on_click=lambda: rx.redirect(docs_url), + size="4", + ), + align="center", + spacing="7", + font_size="2em", + ), + height="100vh", + ) + + +app = rx.App() +app.add_page(index) diff --git a/src/landing/requirements.txt b/src/landing/requirements.txt new file mode 100644 index 0000000..65c472d --- /dev/null +++ b/src/landing/requirements.txt @@ -0,0 +1 @@ +reflex==0.4.3 diff --git a/src/landing/rxconfig.py b/src/landing/rxconfig.py new file mode 100644 index 0000000..c9a1e6d --- /dev/null +++ b/src/landing/rxconfig.py @@ -0,0 +1,5 @@ +import reflex as rx + +config = rx.Config( + app_name="landing", +) \ No newline at end of file