News for hackers. Stuff that matters.
Re:A lesson in dockerizing shell scripts by c0l0 on Saturday February 03, 2024 @10:28AM (#39241196)

   [...]
   COPY --from=ugit-ops /usr/bin/tr /usr/bin/tr
   COPY --from=ugit-ops /bin/bash /bin/
   COPY --from=ugit-ops /bin/sh /bin/
   
   # copy lib files
   COPY --from=ugit-ops /usr/lib/libncursesw.so.6 /usr/lib/
   COPY --from=ugit-ops /usr/lib/libncursesw.so.6.4 /usr/lib/
   COPY --from=ugit-ops /usr/lib/libpcre* /usr/lib/
   COPY --from=ugit-ops /usr/lib/libreadline* /usr/lib/
   [...]
For me, insane sh*t like this proves that those who do not learn from distribution and package management infrastructure engineering history are condemned to reinvent it, poorly.
Re:A lesson in dockerizing shell scripts by bhupesh on Saturday February 03, 2024 @10:33AM (#39241257)
Hey author here.

I understand that you might have some context about package managers that I am missing. Would genuinely like some resources about your comment or maybe a bit of explanation.

Thanks

Re:A lesson in dockerizing shell scripts by c0l0 on Saturday February 03, 2024 @10:40AM (#39241329)
Hey there Bhupesh - apologies for the snark! I was just venting some of the frustration I feel every day with modern "devops" tooling ;)

I am in a bit of a rush right now (which is why I try my absolute best to keep procrastinating on HN at the the absolute minimum, I swear! ;)), but I will try to share some insight later (potentially as a comment on your blog).

Re:A lesson in dockerizing shell scripts by codethief on Saturday February 03, 2024 @11:27AM (#39241836)
I'd be interested in this, too, so I'd be grateful if you could notify us here, wherever you end up posting your comment!
Re:A lesson in dockerizing shell scripts by bhupesh on Saturday February 03, 2024 @10:42AM (#39241361)
Thanks, appreciate the help!
Re:A lesson in dockerizing shell scripts by tiziano88 on Saturday February 03, 2024 @11:38AM (#39241946)
It may be worth looking at Nix if you haven't already
Re:A lesson in dockerizing shell scripts by gbN025tt2Z1E2E4 on Saturday February 03, 2024 @02:21PM (#39243780)
I explained a bit here in my reply to your other comment:

https://news.ycombinator.com/item?id=39243450

Re:A lesson in dockerizing shell scripts by crabique on Saturday February 03, 2024 @09:00PM (#39246798)
At this point, why not just build statically linked binaries of those utils in the build stage and just copy them over? Or even better, have a static build of busybox with all of the non-dependencies disabled. Those filename bytes add up fast!

On unrelated note, --chmod parameter of the COPY instruction provides a way to avoid additional layers just to set the executable bits:

  # instead of
  COPY ugit .
  RUN chmod +x ugit && mv ugit /usr/local/bin/
  COPY --from=builder /usr/local/bin/ugit /usr/bin/

  # could just be this
  COPY ugit --chmod=755 /usr/bin/
In all seriousness though, that Dockerfile is basically one big uglified red flag, please don't do this, people.