Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uv to images that include Python #341

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- Include uv in images that provide Python
-([341](https://github.com/pulumi/pulumi-docker-containers/pull/341))

- Default to Python 3.12 instead of 3.13
([335](https://github.com/pulumi/pulumi-docker-containers/pull/335))

Expand Down
4 changes: 4 additions & 0 deletions docker/pulumi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/
# Set poetry to prefer the active python version so it interacts nicely with pyenv, otherwise
# poetry will create virtual environments using the python version used by poetry itself.
RUN poetry config virtualenvs.prefer-active-python true
# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | XDG_BIN_HOME=/usr/local/share/uv bash -s -- --no-modify-path
RUN ln -s /usr/local/share/uv/uv /usr/local/bin/
RUN ln -s /usr/local/share/uv/uvx /usr/local/bin/

# Install default nodejs versions and associated tools
RUN curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/share/fnm" --skip-shell && \
Expand Down
5 changes: 5 additions & 0 deletions docker/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ RUN apt-get update -y && \
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/share/pypoetry python3 -
RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/

# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | XDG_BIN_HOME=/usr/local/share/uv bash -s -- --no-modify-path
RUN ln -s /usr/local/share/uv/uv /usr/local/bin/
RUN ln -s /usr/local/share/uv/uvx /usr/local/bin/

# Uses the workdir, copies from pulumi interim container
COPY --from=builder /root/.pulumi/bin/pulumi /pulumi/bin/pulumi
COPY --from=builder /root/.pulumi/bin/*-python* /pulumi/bin/
Expand Down
5 changes: 5 additions & 0 deletions docker/python/Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ RUN pyenv global ${LANGUAGE_VERSION}
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/share/pypoetry python3 -
RUN ln -s /usr/local/share/pypoetry/bin/poetry /usr/local/bin/

# Install uv
RUN curl -LsSf https://astral.sh/uv/install.sh | XDG_BIN_HOME=/usr/local/share/uv bash -s -- --no-modify-path
RUN ln -s /usr/local/share/uv/uv /usr/local/bin/
RUN ln -s /usr/local/share/uv/uvx /usr/local/bin/

# Uses the workdir, copies from pulumi interim container
COPY --from=builder /root/.pulumi/bin/pulumi /pulumi/bin/pulumi
COPY --from=builder /root/.pulumi/bin/*-python* /pulumi/bin/
Expand Down
10 changes: 9 additions & 1 deletion tests/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,16 @@ func TestEnvironment(t *testing.T) {
poetryPath, err := exec.LookPath("poetry")
require.NoError(t, err)
require.Equal(t, expectedPoetryPath, poetryPath)
// Use bash `command` builtin to lookup the path to python
// Use bash `command` builtin to lookup the path to poetry
requireOutputWithBash(t, expectedPoetryPath, "command", "-v", "poetry")

// uvy should be available
julienp marked this conversation as resolved.
Show resolved Hide resolved
expectedUvPath := "/usr/local/bin/uv"
uvPath, err := exec.LookPath("uv")
require.NoError(t, err)
require.Equal(t, expectedUvPath, uvPath)
// Use bash `command` builtin to lookup the path to uv
requireOutputWithBash(t, expectedUvPath, "command", "-v", "uv")
})

t.Run("Node", func(t *testing.T) {
Expand Down
Loading