From 08d5db25d69016439d789311136b1ac044813772 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 18 Nov 2025 22:31:32 +0000 Subject: [PATCH] save --- Dockerfile.render | 34 ++++++++++++++++++++++++++++++++++ backend/poetry.lock | 24 +++++++++++++++++++++++- backend/pyproject.toml | 3 ++- backend/src/dashboard/main.py | 1 + render.yaml | 6 ++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.render create mode 100644 render.yaml diff --git a/Dockerfile.render b/Dockerfile.render new file mode 100644 index 0000000..c3feafd --- /dev/null +++ b/Dockerfile.render @@ -0,0 +1,34 @@ +FROM python:3.12-slim + +# DO NOT PUSH IMAGE TO ECR!!! as anyone with access to image can log on to our aws +# Will log on as aws Jun-te account, change in the future to development account +ENV AWS_ACCESS_KEY_ID=AKIAU5A36PPNK7RXX52V +ENV AWS_SECRET_ACCESS_KEY=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 +ENV AWS_DEFAULT_REGION=eu-west-2 + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential curl jq \ + && rm -rf /var/lib/apt/lists/* + +# Install Poetry +RUN pip install poetry + +# Set working directory +WORKDIR /app + +# Copy only Poetry files first (cache layer) +COPY backend/pyproject.toml backend/poetry.lock /app/ + +# Install dependencies without creating a virtualenv +RUN poetry config virtualenvs.create false \ + && poetry install --no-interaction --no-ansi --no-root + +# Copy project code +COPY . /app + +# Expose port (Render uses PORT env var) +EXPOSE 8000 + +# Run Dash app via Gunicorn +CMD ["gunicorn", "backend.src.dashboard.main:server", "--bind", "0.0.0.0:8000"] diff --git a/backend/poetry.lock b/backend/poetry.lock index 1e3bb36..612ee27 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -494,6 +494,28 @@ werkzeug = ">=3.1.0" async = ["asgiref (>=3.2)"] dotenv = ["python-dotenv"] +[[package]] +name = "gunicorn" +version = "23.0.0" +description = "WSGI HTTP Server for UNIX" +optional = false +python-versions = ">=3.7" +groups = ["main"] +files = [ + {file = "gunicorn-23.0.0-py3-none-any.whl", hash = "sha256:ec400d38950de4dfd418cff8328b2c8faed0edb0d517d3394e457c317908ca4d"}, + {file = "gunicorn-23.0.0.tar.gz", hash = "sha256:f014447a0101dc57e294f6c18ca6b40227a4c90e9bdb586042628030cba004ec"}, +] + +[package.dependencies] +packaging = "*" + +[package.extras] +eventlet = ["eventlet (>=0.24.1,!=0.36.0)"] +gevent = ["gevent (>=1.4.0)"] +setproctitle = ["setproctitle"] +testing = ["coverage", "eventlet", "gevent", "pytest", "pytest-cov"] +tornado = ["tornado (>=0.2)"] + [[package]] name = "hubspot-api-client" version = "12.0.0" @@ -1827,4 +1849,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.1" python-versions = ">=3.12" -content-hash = "16f3b01b3600c20d6acd46f8212ec16688c8ad68a5533098789e5f9049011fc6" +content-hash = "e5f24396e682e9ab0a06586c52e2bcc4b9c79c76352b8f752c5f1997808c6b7d" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index e3cb535..4779723 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -15,7 +15,8 @@ dependencies = [ "pandas (>=2.3.3,<3.0.0)", "tqdm (>=4.67.1,<5.0.0)", "boto3 (>=1.40.74,<2.0.0)", - "dash (>=3.3.0,<4.0.0)" + "dash (>=3.3.0,<4.0.0)", + "gunicorn (>=23.0.0,<24.0.0)" ] [tool.poetry] diff --git a/backend/src/dashboard/main.py b/backend/src/dashboard/main.py index 4e3b5d8..50b53a8 100644 --- a/backend/src/dashboard/main.py +++ b/backend/src/dashboard/main.py @@ -90,6 +90,7 @@ unique_dates = ["All Dates"] + list(unique_dates) # Dash App # ------------------------- app = Dash(__name__) +server = app.server # ← REQUIRED for Render/Gunicorn app.layout = html.Div([ html.H1("Line Items by Expected Commencement Date", style={"textAlign": "center"}), diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..0d83ea7 --- /dev/null +++ b/render.yaml @@ -0,0 +1,6 @@ +services: + - type: web + name: dash-dashboard + env: docker + dockerfilePath: ./Dockerfile.render + plan: free