Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Add bash to the image #5

Closed
wants to merge 1 commit into from
Closed

Add bash to the image #5

wants to merge 1 commit into from

Conversation

domenkozar
Copy link
Member

@domenkozar domenkozar commented Nov 2, 2018

It's often useful to have bash available for executing scripts in the container.

I've opted not to use Nix to install bash as that would require fetching nixpkgs, which would make the container much larger.

--no-cache spares some extra storage from the container.

@domenkozar domenkozar requested a review from peti November 2, 2018 11:59
@peti
Copy link
Member

peti commented Nov 2, 2018

I am not sure what you mean ... installing bash via Nix works fine and adds only 27 MB:

$ docker run -it --rm nixos/nix nix-env -p /nix/var/nix/profiles/default -iA nixpkgs.bash
installing 'bash-4.4-p23'
these paths will be fetched (6.82 MiB download, 27.45 MiB unpacked):
  /nix/store/gdcvdm4gxx2bw0h5gslgx3k67wlkpbj1-bash-4.4-p23-info
  /nix/store/hhsyfa5l26ys7m5c1j4fjsr3l323g83w-glibc-2.27
  /nix/store/jlnqfy6ykbnf2nxpmp8in3cxc84rv85p-bash-4.4-p23-dev
  /nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23
  /nix/store/qdpi73cwsnk31dc1qkqp1qvbr47h7nnb-bash-4.4-p23-doc
  /nix/store/wly2g4097ns04m3x00c46fzv5mh64p5x-bash-4.4-p23-man
copying path '/nix/store/qdpi73cwsnk31dc1qkqp1qvbr47h7nnb-bash-4.4-p23-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/gdcvdm4gxx2bw0h5gslgx3k67wlkpbj1-bash-4.4-p23-info' from 'https://cache.nixos.org'...
copying path '/nix/store/wly2g4097ns04m3x00c46fzv5mh64p5x-bash-4.4-p23-man' from 'https://cache.nixos.org'...
copying path '/nix/store/hhsyfa5l26ys7m5c1j4fjsr3l323g83w-glibc-2.27' from 'https://cache.nixos.org'...
copying path '/nix/store/nii7pk6pv4x4as7vsxbvwyzjn67vax6r-bash-4.4-p23' from 'https://cache.nixos.org'...
copying path '/nix/store/jlnqfy6ykbnf2nxpmp8in3cxc84rv85p-bash-4.4-p23-dev' from 'https://cache.nixos.org'...
building '/nix/store/dcrw1zc92a6ri3bga9i7v3sjypkpfrhd-user-environment.drv'...
created 32 symlinks in user environment

Generally speaking, though, I'd rather not add bash. It's not essential for anything and many prople (like myself) don't use bash. I feel like adding this kind of nice-to-have packages is best accomplished in a derived container that inherits the base installation from this one.

@@ -3,7 +3,7 @@
FROM alpine

# Enable HTTPS support in wget.
RUN apk add --update openssl
RUN apk add --update --no-cache openssl bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding && apk cache clean at the end of this command, too? We shouldn't need the cache after this point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand how apk works, but running with --no-cache means there's no cache to clean up. Are you proposing to do that instead of --no-cache?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good question. I just ran apk cache clean in a pristine Alpine image, and it said ERROR: Package cache is not enabled.. Sp that command clearly makes no sense here.

Now I wonder whether --no-cache makes any difference?

@domenkozar
Copy link
Member Author

domenkozar commented Nov 2, 2018

That's a bit contradictory statement because image increased by 3MB, which at the uncompressed size of 158MB is less than 2% difference. Using Nix we'd be increasing by 17%.

don't use bash

I understand not everyone needs bash, but those that do (for example using the image with a CI) this is really nice.

I do see your point, if we add too much stuff we're better of at maintaining -minimal and -full, but I really don't think it's worth doing that change for extra 3MB.

@domenkozar
Copy link
Member Author

Oh and another thing, nix-shell these days depends on bash anyway: https://github.com/NixOS/nix/blob/f6a3dfe4e06980b2d060fd1a646cb5ca20f29779/src/nix-build/nix-build.cc#L340

@peti
Copy link
Member

peti commented Nov 2, 2018

I do see your point, if we add too much stuff we're better of at maintaining -minimal and -full, but I really don't think it's worth doing that change for extra 3MB.

The beauty of it is that we don't have to do anything at all. Anybody who wants to base his personalized docker image on ours can do so just fine without coordinating with us in any way. Just create a derived image and add anything you want. There's no need to do that here.

@domenkozar
Copy link
Member Author

OK, would you be opposed to having another image in this repo then, which would include the common tooling?

@peti
Copy link
Member

peti commented Nov 2, 2018

I would rather not have another image in this Git repo, but I think it would be fine to have another, separate Git repository that's built and published in docker's NixOS organization. I'm not sure what a good name would be ... maybe nixos/nix-dev-env?

@domenkozar
Copy link
Member Author

@garbas to answer your question why are low hanging fruits like this not done, but they are so easy? Well, there's always someone that doesn't like something because we're sparing 3MB to trade convenience, so I'm happy if you take this battle on, I'm giving up for now.

@domenkozar domenkozar closed this Nov 2, 2018
peti added a commit that referenced this pull request Nov 2, 2018
Suggested by @domenkozar in #5. With this
change, /var/cache/apk is empty at the time we try to clean it, so we must use
--force to prevent the build from failing.
@peti
Copy link
Member

peti commented Nov 2, 2018

there's always someone that doesn't like something because we're sparing 3MB to trade convenience

That is a pretty unfair description of the situation. I couldn't care less about 3MB. My concern is that we should implement this kind of thing properly. For starters, the notion of using apk to install bash feels odd considering that we have a full-blown Nix installation at our disposal -- which will download and install bash anyway if you use it for any non-trivial purposes. So I'd much rather install an additional 20MB but have a bash that Nix can use.

Furthermore, I believe that many people don't care for bash (such as myself) and that we should not provide one in the default image since bash is unnecessary for building this particular installation. Instead, we should use inheritance to create a separate image that provides Nix+bash without polluting our base. This is really simple, and I have done exactly that myself a while ago, i.e. in https://github.com/peti/hex2017/blob/master/Dockerfile#L9-L15.

So the reason why I kinda resist your low-hanging-fruit solution is because I think it's a bad solution.
I'd be hugely in favor of providing a proper solution, but it appears that you don't want to put the effort in that's necessary to create it.

@peti peti deleted the bash branch January 21, 2019 17:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants