From 83b0efd4d753028275144fc243b5bfb5ec601faa Mon Sep 17 00:00:00 2001 From: EED85 Date: Fri, 25 Jul 2025 06:40:44 +0200 Subject: [PATCH 01/11] first try [no ci] --- .devcontainer/Dockerfile | 17 +++++++++++++++++ .devcontainer/devcontainer.json | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..2009aaa --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Python image +FROM mcr.microsoft.com/devcontainers/python:3.13 + +# Install dependencies +RUN apt-get update && apt-get install -y curl unzip + +# Install uv (latest release from GitHub) +RUN curl -sSL https://astral.sh/uv/install.sh | bash + +# Add uv to PATH +ENV PATH="/root/.cargo/bin:$PATH" + +# Set working directory +WORKDIR /workspace + +# Default shell +SHELL ["/bin/bash", "-c"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d2ce518 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,17 @@ +{ + "name": "uv-python-dev", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.vscode-pylance" + ] + } + }, + "postCreateCommand": "uv venv && uv sync", + "features": {}, + "remoteUser": "vscode" +} From f2be87b59fa5d126e98808f47e2733fd181cea57 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 04:47:00 +0000 Subject: [PATCH 02/11] uv command does not work [no ci] --- .devcontainer/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2009aaa..c2a1acf 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -4,8 +4,10 @@ FROM mcr.microsoft.com/devcontainers/python:3.13 # Install dependencies RUN apt-get update && apt-get install -y curl unzip -# Install uv (latest release from GitHub) -RUN curl -sSL https://astral.sh/uv/install.sh | bash +# Install uv globally (latest release from GitHub) +RUN curl -sSf https://astral.sh/uv/install.sh | bash && \ + ln -s /root/.cargo/bin/uv /usr/local/bin/uv + # Add uv to PATH ENV PATH="/root/.cargo/bin:$PATH" From 275bdf1f47f3700a98e7409c1a25c3628587f9c1 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 04:53:14 +0000 Subject: [PATCH 03/11] try new approach [no ci] --- .devcontainer/Dockerfile | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c2a1acf..02fa8ef 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,19 +1,27 @@ # Use the official Python image -FROM mcr.microsoft.com/devcontainers/python:3.13 +FROM FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim -# Install dependencies -RUN apt-get update && apt-get install -y curl unzip +# Install the project into `/app` +WORKDIR /app +# Enable bytecode compilation +ENV UV_COMPILE_BYTECODE=1 +# Copy from the cache instead of linking since it's a mounted volume +ENV UV_LINK_MODE=copy +# Install the project's dependencies using the lockfile and settings +RUN --mount=type=cache,target=/root/.cache/uv \ +--mount=type=bind,source=uv.lock,target=uv.lock \ +--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ +uv sync --frozen --no-install-project --no-dev -# Install uv globally (latest release from GitHub) -RUN curl -sSf https://astral.sh/uv/install.sh | bash && \ - ln -s /root/.cargo/bin/uv /usr/local/bin/uv - - -# Add uv to PATH -ENV PATH="/root/.cargo/bin:$PATH" - -# Set working directory -WORKDIR /workspace +ADD . /app +RUN --mount=type=cache,target=/root/.cache/uv \ +uv sync --frozen --no-dev +# Place executables in the environment at the front of the path +ENV PATH="/app/.venv/bin:$PATH" +# Reset the entrypoint, don't invoke `uv` +ENTRYPOINT [] +# Run the FastAPI application by default +CMD ["fastapi", "dev", "--host", "0.0.0.0", "src/uv_docker_example"] # Default shell SHELL ["/bin/bash", "-c"] From 155c99e60add82a968074c3ab2dadd00f6663175 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 04:59:24 +0000 Subject: [PATCH 04/11] copy uv.lock file [no ci] --- .devcontainer/Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 02fa8ef..ff556cf 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,11 +1,17 @@ # Use the official Python image -FROM FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim +FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim # Install the project into `/app` WORKDIR /app # Enable bytecode compilation ENV UV_COMPILE_BYTECODE=1 # Copy from the cache instead of linking since it's a mounted volume + + +# Copy only the lockfile and pyproject.toml first (for caching) +COPY uv.lock pyproject.toml ./ + + ENV UV_LINK_MODE=copy # Install the project's dependencies using the lockfile and settings RUN --mount=type=cache,target=/root/.cache/uv \ From 46ab478cd9d12bb31d4bff63715f96e6c7915b1b Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:03:24 +0000 Subject: [PATCH 05/11] keep uv usage from docker [no ci] --- .devcontainer/Dockerfile | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ff556cf..4e5cfcc 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,33 +1,9 @@ # Use the official Python image -FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim +FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim # Install the project into `/app` WORKDIR /app -# Enable bytecode compilation -ENV UV_COMPILE_BYTECODE=1 -# Copy from the cache instead of linking since it's a mounted volume - - -# Copy only the lockfile and pyproject.toml first (for caching) -COPY uv.lock pyproject.toml ./ - - -ENV UV_LINK_MODE=copy -# Install the project's dependencies using the lockfile and settings -RUN --mount=type=cache,target=/root/.cache/uv \ ---mount=type=bind,source=uv.lock,target=uv.lock \ ---mount=type=bind,source=pyproject.toml,target=pyproject.toml \ -uv sync --frozen --no-install-project --no-dev - ADD . /app -RUN --mount=type=cache,target=/root/.cache/uv \ -uv sync --frozen --no-dev -# Place executables in the environment at the front of the path -ENV PATH="/app/.venv/bin:$PATH" -# Reset the entrypoint, don't invoke `uv` -ENTRYPOINT [] -# Run the FastAPI application by default -CMD ["fastapi", "dev", "--host", "0.0.0.0", "src/uv_docker_example"] # Default shell SHELL ["/bin/bash", "-c"] From c9a9f0cfd79579d648f9bba0a7987eee475d60c1 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:15:54 +0000 Subject: [PATCH 06/11] docker runs [no ci] --- .devcontainer/Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4e5cfcc..d050d18 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,5 +5,18 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim WORKDIR /app ADD . /app + +# Install system packages: +# git +RUN apt-get update && apt-get install -y git +# duckdb +RUN curl -sL https://install.duckdb.org | sh + + # Default shell SHELL ["/bin/bash", "-c"] + + +# Create vscode user to satisfy Codespaces requirement +RUN useradd -m vscode +USER vscode From cb431fe8191fa23e9bbb2d4373de72a5193e0409 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:23:09 +0000 Subject: [PATCH 07/11] uv sync no works [no ci] --- .devcontainer/devcontainer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d2ce518..b52b13c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,10 +8,13 @@ "extensions": [ "ms-python.python", "ms-python.vscode-pylance" - ] + ], + "settings": { + "terminal.integrated.defaultProfile.linux": "bash" + } } }, - "postCreateCommand": "uv venv && uv sync", + "postCreateCommand": "uv venv --force && uv sync -v", "features": {}, "remoteUser": "vscode" } From 1ab844b96a8c226311d16cb3569930885fa68652 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 05:43:13 +0000 Subject: [PATCH 08/11] update some basic settings and add some extesnions [no ci] --- .devcontainer/devcontainer.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b52b13c..568b4f3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,10 +7,22 @@ "vscode": { "extensions": [ "ms-python.python", - "ms-python.vscode-pylance" + "ms-python.vscode-pylance", + "charliermarsh.ruff", + "atlassian.atlascode", + "njpwerner.autodocstring", + "ms-azuretools.vscode-docker", + "github.vscode-github-actions", + "eamodio.gitlens", + "ms-toolsai.jupyter", + "mechatroner.rainbow-csv", ], "settings": { - "terminal.integrated.defaultProfile.linux": "bash" + "terminal.integrated.defaultProfile.linux": "bash", + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, + "files.autoSave": "afterDelay", } } }, From b204d819c5e68a2d15027c97a16d3bbade679335 Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 06:20:40 +0000 Subject: [PATCH 09/11] gh installed now [no ci] --- .devcontainer/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d050d18..a67a8d0 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,10 +7,25 @@ ADD . /app # Install system packages: +# curl +RUN apt-get update && apt-get install -y curl + +RUN apt-get update && apt-get install -y gnupg + # git RUN apt-get update && apt-get install -y git # duckdb RUN curl -sL https://install.duckdb.org | sh +#11 1.139 Successfully installed DuckDB binary to /root/.duckdb/cli/1.3.2/duckdb +#11 1.140 with a link from /root/.duckdb/cli/latest/duckdb +# github cli + +RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ + gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \ + tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \ + apt-get update && apt-get install -y gh + # Default shell From 92ed1485674a546fd2a0a01b298b72561cdad9cb Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 06:28:14 +0000 Subject: [PATCH 10/11] duckdb installed [no ci] --- .devcontainer/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a67a8d0..42b40e4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -18,8 +18,15 @@ RUN apt-get update && apt-get install -y git RUN curl -sL https://install.duckdb.org | sh #11 1.139 Successfully installed DuckDB binary to /root/.duckdb/cli/1.3.2/duckdb #11 1.140 with a link from /root/.duckdb/cli/latest/duckdb -# github cli + +# Install DuckDB CLI +RUN curl -sL https://install.duckdb.org | sh && \ + mkdir -p /usr/local/bin && \ + cp /root/.duckdb/cli/latest/duckdb /usr/local/bin/duckdb && \ + chmod +x /usr/local/bin/duckdb + +# github cli RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg && \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | \ From 022fa30762d8741cc987aeb4733a2f1e77ddf16b Mon Sep 17 00:00:00 2001 From: Eric Brahmann <37987769+EED85@users.noreply.github.com> Date: Fri, 25 Jul 2025 06:30:09 +0000 Subject: [PATCH 11/11] clean --- .devcontainer/Dockerfile | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 42b40e4..2c1d0d9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,27 +5,18 @@ FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim WORKDIR /app ADD . /app - # Install system packages: # curl RUN apt-get update && apt-get install -y curl - +# gnupg RUN apt-get update && apt-get install -y gnupg - # git RUN apt-get update && apt-get install -y git # duckdb -RUN curl -sL https://install.duckdb.org | sh -#11 1.139 Successfully installed DuckDB binary to /root/.duckdb/cli/1.3.2/duckdb -#11 1.140 with a link from /root/.duckdb/cli/latest/duckdb - - -# Install DuckDB CLI RUN curl -sL https://install.duckdb.org | sh && \ mkdir -p /usr/local/bin && \ cp /root/.duckdb/cli/latest/duckdb /usr/local/bin/duckdb && \ chmod +x /usr/local/bin/duckdb - # github cli RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg && \ @@ -33,12 +24,9 @@ RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | \ tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \ apt-get update && apt-get install -y gh - - # Default shell SHELL ["/bin/bash", "-c"] - # Create vscode user to satisfy Codespaces requirement RUN useradd -m vscode USER vscode