Skip to content

Commit

Permalink
Add uv to images that include Python
Browse files Browse the repository at this point in the history
Now that the Pulumi CLI supports uv out of the box, include it in the docker images.

Fixes #340
  • Loading branch information
julienp committed Dec 16, 2024
1 parent 182e5b6 commit 74981a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
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
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, expectedPoetryPath, "command", "-v", "uv")
})

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

0 comments on commit 74981a2

Please sign in to comment.