From 2e03f31a095f69d8f82af2f3d485a247ce4edb90 Mon Sep 17 00:00:00 2001 From: "Waylon S. Walker" Date: Tue, 29 Oct 2024 20:14:57 -0500 Subject: [PATCH] docker --- Dockerfile | 150 +++++++++++++++++++++++++++++++++------ justfile | 32 ++++++--- k8s/base/deployment.yaml | 145 +++++++++++++++++++++++++++++++++++++ 3 files changed, 296 insertions(+), 31 deletions(-) create mode 100644 k8s/base/deployment.yaml diff --git a/Dockerfile b/Dockerfile index a1a1506..309b99d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,136 @@ -from python:3.13 +FROM ubuntu:noble AS build + +# The following does not work in Podman unless you build in Docker +# compatibility mode: +# You can manually prepend every RUN script with `set -ex` too. +# SHELL ["sh", "-exc"] + +### Start build prep. +### This should be a separate build container for better reuse. + +RUN < src/fastapi_dynamic_response/__about__.py +touch README.md +uv sync \ + --locked \ + --no-dev \ + --no-install-project +EOT + +# Now install the APPLICATION from `/src` without any dependencies. +# `/src` will NOT be copied into the runtime container. +# LEAVE THIS OUT if your application is NOT a proper Python package. +# As of uv 0.4.11, you can also use +# `cd /src && uv sync --locked --no-dev --no-editable` instead. +COPY . /src +RUN --mount=type=cache,target=/root/.cache \ + uv pip install \ + --python=$UV_PROJECT_ENVIRONMENT \ + --no-deps \ + /src + + +########################################################################## + +FROM ubuntu:noble +# SHELL ["sh", "-exc"] + +# Optional: add the application virtualenv to search path. +ENV PATH=/app/bin:$PATH + +# Don't run your app as root. +RUN <. +STOPSIGNAL SIGINT + +# Note how the runtime dependencies differ from build-time ones. +# Notably, there is no uv either! +RUN <