Skip to content

Conversation

@felipecrs
Copy link
Contributor

  1. Update Debian from 10 to 12 (current latest)
  2. Avoid installing apt-get dependencies, pkgx is meant to handle them all I suppose (maybe they were needed by pkgx v1?)
  3. Remove bashrc craziness, they cause issues when running image as a different user like --user $(id -u):$(id -g) and I don't see why they are needed
  4. Remove CLICOLOR_FORCE=1. This is non-sense. pkgx v2 already adds colors when the container is being run with -it.

The old image size was 176MB, the new image size is 86.6MB.

@mxcl
Copy link
Member

mxcl commented Mar 12, 2025

We'd have to update a lot of docs and a large amount of infra for these changes. What is your goal?

@felipecrs
Copy link
Contributor Author

We'd have to update a lot of docs and a large amount of infra for these changes.

Can you point to some example, please? I thought I had not broken any use case.

@mxcl
Copy link
Member

mxcl commented Mar 12, 2025

For one the packages we install are required packages on Linux. So dozens (hundreds?) of pkgx packages will no longer work if we remove them. The bash stuff is so the usage examples we offer for our image work. I added CLICOLOR_FORCE because otherwise colors were not working. The debian choice is so we use the correct glibc, and while it should be safe to upgrade it I'd rather not considering we have not tested anything else.

What is your goal?

Our goal for this image is for demonstration purposes.

What do you seek to do with these changes?

@felipecrs
Copy link
Contributor Author

felipecrs commented Mar 12, 2025

For one the package we install are required packages on Linux. So dozens of pkgx packages will no longer work.

Can you point me to one? I tested running some crazy packages like Java and Python, and a few other, they all worked fine.

What is your goal?

I want to use this image in some of my docker-compose.yaml to run maintenance scripts. Example:

services:
  database:
    image: postgres
  maintainer:
    image: pkgxdev/pkgx:v2
    volumes:
      - ./scripts:/maintainer/scripts
    entrypoint:
      - bash
      - -c
      - set -eux; while true; do /maintainer/scripts/cleanup_db.sh; sleep 1h done;

And then in my script something like:

#!/bin/bash

pkgx_env="$(pkgx +psql +jq +yq +curl)"
set -o allexport
eval "${pkgx_env}"
set +o allexport
unset pkgx_env

...

What do you seek to do with these changes?

Well, to do what docker images are supposed to: allow for running applications (pkgx in this case) in a portable manner without having to install it.

Not just to run a simple command like for demonstration, but for more serious cases.

@mxcl
Copy link
Member

mxcl commented Mar 24, 2025

We will make a much leaner image when https://github.com/pkgxdev/manifests is ready. I am doing the work currently so that our packages only depend on glibc and nothing else.

Can you point me to one? I tested running some crazy packages like Java and Python, and a few other, they all worked fine.

It's all builds related. But the fact is if you use pkgx and want to build eg. C++ these packages are required. While we could just say this in the docs we try to build things that just work. The pkgx installer also installs these packages (in CI, otherwise it just outputs a message saying they are required).

@felipecrs
Copy link
Contributor Author

I see.

But the fact is if you use pkgx and want to build eg. C++ these packages are required.

We could provide an additional variant of the pkgx docker image that is capable of building. Or maybe even make it as an image for brewkit instead of pkgx.

@mxcl mxcl force-pushed the main branch 14 times, most recently from 7c8ed9c to ebf754b Compare March 25, 2025 18:20
@mxcl
Copy link
Member

mxcl commented Mar 26, 2025

image

This is based on busybox:1.31-glibc which provides the glibc we build against.

glibc is forwards compatible so we could use the most recent glibc instead. busybox is tiny while still providing POSIX though there are caveats. In future would be fun to provide POSIX as pkgx shims. Not sure what image we should pick for now, but the above screenshot shows where we are at with a tiny 17MB image.

Here’s the Dockerfile:

FROM debian:buster-slim AS stage1
RUN apt-get update && apt-get install -y curl
RUN curl https://pkgx.sh | sh
RUN echo "#!/usr/bin/env -S pkgx -q! bash" > /bin/bash
RUN chmod +x /bin/bash

FROM busybox:1.31-glibc AS stage2
COPY --from=stage1 /usr/local/bin/pkgx /usr/local/bin/pkgx
COPY --from=stage1 /usr/local/bin/pkgm /usr/local/bin/pkgm
COPY --from=stage1 /lib/x86_64-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
COPY --from=stage1 /lib/x86_64-linux-gnu/librt-2.28.so /lib/librt.so.1
COPY --from=stage1 /lib/x86_64-linux-gnu/libdl-2.28.so /lib/libdl.so.2
COPY --from=stage1 /usr/bin/env /usr/bin/env
COPY --from=stage1 /usr/bin/ldd /usr/bin/ldd
COPY --from=stage1 /bin/bash /bin/bash

SHELL ["/bin/sh", "-c"]
CMD ["/bin/sh", "-i"]
ENTRYPOINT ["/usr/local/bin/pkgx"]

@felipecrs
Copy link
Contributor Author

felipecrs commented Mar 26, 2025

That's awesome. I personally don't like Busybox because it has no package manager to help adding more packages to the image, but maybe having pkgx is enough to fulfill that whole.

@mxcl
Copy link
Member

mxcl commented Mar 26, 2025

We can provide multiple images easily enough. What base container would you like?

@felipecrs
Copy link
Contributor Author

I think having a Debian (Slim) or Ubuntu variant could be useful:

image

But maybe the best starter is the Alpine variant? It's marginally bigger than busybox.

I'm not asking for the Debian variant yet; I haven't found a specific need for it.

I think you should add more variants as needed. Maybe it will never be needed, who knows.

@mxcl
Copy link
Member

mxcl commented Mar 26, 2025

Alpine is no good until we have our own glibc package or we can find a good way to get glibc and libgcc into alpine. I looked into it and there was nothing trivial, but it's probably just a bit of work to do it

@felipecrs
Copy link
Contributor Author

Maybe go for busybox then. :)

Tag it with something like pkgdev/pkgx:v2.5.0-busybox if you don't want to commit future compatibility with the main variant yet.

@mxcl
Copy link
Member

mxcl commented Mar 26, 2025

#1157

@mxcl mxcl force-pushed the main branch 11 times, most recently from bda3509 to de3497e Compare April 2, 2025 17:13
@felipecrs
Copy link
Contributor Author

Superseded by #1157.

@felipecrs felipecrs closed this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants