From 986b8ba6324b64b9f1a031bc548d9d76fbe2dd50 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Thu, 24 Oct 2024 09:36:10 -0500 Subject: [PATCH] add Docker --- Dockerfile | 30 ++++++++++++++++++++++++++++++ justfile | 27 ++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a1a1506 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +from python:3.13 +WORKDIR /app +COPY src src +COPY pyproject.toml . +COPY uv.lock . +COPY README.md . +COPY requirements.txt . + +ENV VIRTUAL_ENV=/app/.venv +ENV PATH=${VIRTUAL_ENV}/bin:${PATH} + +RUN useradd -m appuser && chown -R appuser:appuser /app +USER appuser + +ENV HOME=/home/appuser +ENV PATH=${HOME}/.local/bin:${PATH} + +RUN pip install --upgrade pip && \ + pip install uv && \ + uv venv +RUN uv pip install -r requirements.txt +RUN uv pip install . + +COPY static static +COPY templates templates + +EXPOSE 8000 + +ENTRYPOINT ["uvicorn"] +CMD ["src.fastapi_dynamic_response.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/justfile b/justfile index fc27423..fef9821 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,34 @@ +set dotenv-load + default: @just --choose +setup: kind-create argo-install + +teardown: kind-delete + +kind-create: + kind create cluster --name fastapi-dynamic-response + +kind-delete: + kind delete cluster --name fastapi-dynamic-response + +argo-install: + kubectl create namespace argocd + kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml + kubectl get pods -n argocd + kubectl apply -f argo + +compile: + uv pip compile pyproject.toml -o requirements.txt venv: uv venv - +build-podman: + podman build -t docker.io/waylonwalker/fastapi-dynamic-response:0.0.2 . +run-podman: + podman run -it --rm -p 8000:8000 --name fastapi-dynamic-response docker.io/waylonwalker/fastapi-dynamic-response:0.0.2 +push-podman: + podman push docker.io/waylonwalker/fastapi-dynamic-response:0.0.2 run: uv run -- uvicorn --reload --log-level debug src.fastapi_dynamic_response.main:app