From c14a229801b53e67118acfac709acdf30fb9a481 Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser (@tux-six) Date: Tue, 12 Jul 2022 23:38:51 +0200 Subject: (DockerBuild) Add hint about how to build for debian plus some cleanup --- README.md | 14 +++-------- contrib/build-using-docker/Dockerfile | 9 ++++--- contrib/build-using-docker/README.md | 47 +++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 5b7bc29..daef2a2 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,10 @@ create many links. ## How to build / install -Minimal way is to do: +If you prefer to build within more isolated environment may +"contrib/build-using-docker/README.md" could be interesting for you. + +If you prefer traditional, just do: ```sh curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/snapshot/bulk-ln-master.tar.gz | tar xz @@ -18,12 +21,3 @@ Minimal way is to do: make install ``` -As usual, configure provides some help: - -```sh - ./configure --help -``` - -Its worth browsing the "contrib/" directory. It contains potentially useful -scripts for building. - diff --git a/contrib/build-using-docker/Dockerfile b/contrib/build-using-docker/Dockerfile index 78f1a85..9a6df6b 100644 --- a/contrib/build-using-docker/Dockerfile +++ b/contrib/build-using-docker/Dockerfile @@ -4,25 +4,26 @@ FROM $PARENT_IMAGE ARG GIT_TAG= ARG CONFIGURE_OPTS= -ARG PKGS_TO_INSTALL="curl gcc git make musl-dev tar" ARG PKGINIT=true ARG PKGADD="apk add" ARG PKGDEL="apk del" ARG PKGCLEAN=true +ARG PKGS_TO_ADD="curl gcc git make musl-dev tar" +ARG PKGS_TO_DEL="curl gcc git make musl-dev tar" WORKDIR /work RUN true \ && $PKGINIT \ - && $PKGADD $PKGS_TO_INSTALL \ - && git clone https://git.hiddenalpha.ch/bulk-ln.git . \ + && $PKGADD $PKGS_TO_ADD \ + && git clone --depth 1 https://github.com/hiddenalpha/bulk-ln.git . \ && git config advice.detachedHead false \ && if test -n "$GIT_TAG"; then git checkout "$GIT_TAG"; fi \ && ./configure $CONFIGURE_OPTS \ && make clean && make && make install \ && find . -not -wholename './dist*' -delete \ && find /work -exec chown 1000:1000 {} + \ - && $PKGDEL $PKGS_TO_INSTALL \ + && $PKGDEL $PKGS_TO_DEL \ && $PKGCLEAN \ && true diff --git a/contrib/build-using-docker/README.md b/contrib/build-using-docker/README.md index 503136e..35f7429 100644 --- a/contrib/build-using-docker/README.md +++ b/contrib/build-using-docker/README.md @@ -2,28 +2,59 @@ Showcase how to build and install ================================= -Make and install inside a dockerimage. +Sometimes happy developers (like me) have no choice but using horribly +restricted systems where setting up tools to run even something as simple as +configure/make/install becomes a nightmare. I found it to be easier to have a +Dockerfile to build on a totally unrelated machine (but where I have the needed +privileges) and then just copy-paste the built result over to where I need it. + + +## Setup variable to reduce annoying repetitions ```sh - curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/plain/contrib/build-using-docker/Dockerfile | sudo docker build . -f - +IMG=bulk-ln-showcase:latest ``` -Afer that we can use the image hash printed in last line to refer to our built -image (replace IMG_REF in commands below by that hash). Alternatively we could -add [`--tag`](https://docs.docker.com/engine/reference/commandline/build/) -option to our build command to give the resulting image a name. +## Make and install dockerimage + +```sh +curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/plain/contrib/build-using-docker/Dockerfile | sudo docker build . -f - -t "${IMG:?}" +``` + +## Grab distribution archive Most probably we wanna get the distribution archive. We can copy it out the dockerimage to our host using: ```sh - sudo docker run --rm -i IMG_REF sh -c 'true && cd dist && tar c *' | tar x +sudo docker run --rm -i "${IMG:?}" sh -c 'true && cd dist && tar c *' | tar x ``` + +## Play around + Or if we wanna browse the image or play around with the built utility we could launch a shell. Once in the shell, try `bulk-ln --help`. ```sh - sudo docker run --rm -ti IMG_REF sh +sudo docker run --rm -ti "${IMG:?}" sh +``` + + +## Other targets + +The dockerfile is parameterized and should work for other systems too. For +example to compile for debian we could use command like below. May set *IMG* +differently if you need to keep multiple images. + +```sh +curl -sSL http://git.hiddenalpha.ch/bulk-ln.git/plain/contrib/build-using-docker/Dockerfile | sudo docker build . -f - -t "${IMG:?}" \ + --build-arg PARENT_IMAGE=debian:buster-20220622-slim \ + --build-arg PKGS_TO_ADD="curl gcc git make libc-dev ca-certificates tar" \ + --build-arg PKGS_TO_DEL="curl gcc git make libc-dev ca-certificates" \ + --build-arg PKGINIT="apt update" \ + --build-arg PKGADD="apt install -y --no-install-recommends" \ + --build-arg PKGDEL=true \ + --build-arg PKGCLEAN="apt clean" ``` -- cgit v1.1