From 74876c73ae45ed02b4f0ff45f317e59abb6212a1 Mon Sep 17 00:00:00 2001 From: Brandon Durepo Date: Fri, 20 Dec 2024 22:37:50 -0800 Subject: [PATCH 1/5] Added multi-stage Docker build and hamlib-runtime image --- docker-build/Dockerfile | 30 ++++++++++++++++++------------ docker-build/README.docker | 14 ++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docker-build/Dockerfile b/docker-build/Dockerfile index 0700fbcac..658a1b7bb 100644 --- a/docker-build/Dockerfile +++ b/docker-build/Dockerfile @@ -1,21 +1,27 @@ -# Idea from https://github.com/ok2cqr/cqrlog +# Base Image +FROM ubuntu:latest AS hamlib-base-image -FROM ubuntu:latest +ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" -RUN apt-get update && apt-get -y upgrade +RUN apt-get update && apt-get install -y build-essential automake libtool python3 && rm -rf /var/lib/apt/lists/* -ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/London" +# Builder Image +FROM hamlib-base-image AS hamlib-builder -RUN apt-get install -y git build-essential automake libtool +COPY . /tmp/build -RUN mkdir -p /usr/local/hamlib-alpha /home/hamlib/build +WORKDIR /tmp/build -# Mount point for the git repository: -VOLUME ["/home/hamlib/build"] +RUN mkdir -p /tmp/local -# Mount point for the result of the build: -VOLUME ["/usr/local/hamlib-alpha"] +RUN ./bootstrap && ./configure --prefix=/tmp/local \ + && make clean && make -j && make install -WORKDIR /home/hamlib/build +# Runtime Image +FROM ubuntu:latest AS hamlib-runtime -ENTRYPOINT rm -rf build && mkdir -p build && cd build && ../bootstrap && ../configure --prefix=/usr/local/hamlib-alpha && make clean && make && make install +COPY --from=hamlib-builder /tmp/local/bin /usr/local/bin +COPY --from=hamlib-builder /tmp/local/lib /usr/local/lib +COPY --from=hamlib-builder /tmp/local/share /usr/local/share + +ENV LD_LIBRARY_PATH="/usr/local/lib" diff --git a/docker-build/README.docker b/docker-build/README.docker index c5ed7822c..9c3cbe693 100644 --- a/docker-build/README.docker +++ b/docker-build/README.docker @@ -1,13 +1,7 @@ -This is all about building hamlib inside docker container - so that you do not need to install dependencies on your local machine. -1. Build docker container +# Build, execute from the repository root +`docker buildx build -t hamlib-runtime -f docker-build/Dockerfile .` -(cd docker-build && docker build --no-cache -t this.registry.is.invalid/hamlib-build .) +# Run the hamlib-runtime +`docker run -it hamlib-runtime bash` -2. Build hamlib - -docker run -ti -u root -v $(pwd):/home/hamlib/build -v /usr/local/hamlib-alpha:/usr/local/hamlib-alpha this.registry.is.invalid/hamlib-build - -3. Execute hamlib - -/usr/local/hamlib-alpha/bin/rigctl From 5028a0c440e7643c25ae459f6150c8313b223a7d Mon Sep 17 00:00:00 2001 From: Brandon Durepo Date: Fri, 20 Dec 2024 23:05:03 -0800 Subject: [PATCH 2/5] Added multi-platform support for linux/arm64 and linux/amd64 --- docker-build/README.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-build/README.docker b/docker-build/README.docker index 9c3cbe693..44a031344 100644 --- a/docker-build/README.docker +++ b/docker-build/README.docker @@ -1,6 +1,6 @@ # Build, execute from the repository root -`docker buildx build -t hamlib-runtime -f docker-build/Dockerfile .` +`docker buildx build --platform linux/amd64,linux/arm64 -t hamlib-runtime -f docker-build/Dockerfile .` # Run the hamlib-runtime `docker run -it hamlib-runtime bash` From 50e10f758223e456e1304e7b8ae8d2092d89a914 Mon Sep 17 00:00:00 2001 From: Brandon Durepo Date: Sat, 21 Dec 2024 07:52:54 -0800 Subject: [PATCH 3/5] Add support for the hamlib-base-image and hamlib-runtime targets - support the arm64 and amd64 platforms on both a base-image and runtime --- docker-build/Dockerfile | 19 +++++----- docker-build/README.Docker.md | 71 +++++++++++++++++++++++++++++++++++ docker-build/README.docker | 7 ---- 3 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 docker-build/README.Docker.md delete mode 100644 docker-build/README.docker diff --git a/docker-build/Dockerfile b/docker-build/Dockerfile index 658a1b7bb..d5c490a73 100644 --- a/docker-build/Dockerfile +++ b/docker-build/Dockerfile @@ -3,25 +3,24 @@ FROM ubuntu:latest AS hamlib-base-image ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" -RUN apt-get update && apt-get install -y build-essential automake libtool python3 && rm -rf /var/lib/apt/lists/* +RUN apt-get update \ + && apt-get install -y build-essential automake libtool python3.6 \ + && rm -rf /var/lib/apt/lists/* # Builder Image + FROM hamlib-base-image AS hamlib-builder -COPY . /tmp/build +COPY . /wip -WORKDIR /tmp/build +WORKDIR /wip -RUN mkdir -p /tmp/local - -RUN ./bootstrap && ./configure --prefix=/tmp/local \ - && make clean && make -j && make install +RUN ./bootstrap && ./configure --prefix=/usr/local \ + && make clean && make -j${nproc} && make install # Runtime Image FROM ubuntu:latest AS hamlib-runtime -COPY --from=hamlib-builder /tmp/local/bin /usr/local/bin -COPY --from=hamlib-builder /tmp/local/lib /usr/local/lib -COPY --from=hamlib-builder /tmp/local/share /usr/local/share +COPY --from=hamlib-builder /usr/local /usr/local ENV LD_LIBRARY_PATH="/usr/local/lib" diff --git a/docker-build/README.Docker.md b/docker-build/README.Docker.md new file mode 100644 index 000000000..7e2af0a9d --- /dev/null +++ b/docker-build/README.Docker.md @@ -0,0 +1,71 @@ + +# Build the hamlib-runtime from the repository root + +``` +docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --target hamlib-runtime \ + -t hamlib-runtime \ + -f docker-build/Dockerfile \ + . +``` + +# Interactively, develop with the hamlib-base-image + + +## Support the linux/amd64 and linux/arm64 platforms +``` +docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --target hamlib-base-image \ + -t hamlib-base-image \ + -f docker-build/Dockerfile \ + . +``` + +## Develop on the linux/amd64 hamlib-base-image + +``` +docker run \ + -it \ + --rm \ + --platform linux/amd64 \ + -v $(pwd):/wip \ + -w /wip \ + -u $(id -u):$(id -g) \ + hamlib-base-image bash +``` + +...or the linux/arm64 hamlib-base-image + +``` +docker run \ + -it \ + --rm \ + --platform linux/arm64 \ + -v $(pwd):/wip \ + -w /wip \ + -u $(id -u):$(id -g) \ + hamlib-base-image bash +``` + +# Run the linux/amd64 hamlib-runtime + +``` +docker run \ + -it \ + --rm \ + --platform linux/amd64 \ + hamlib-runtime bash +``` + + ...or the linux/arm64 hamlib-runtime + +``` +docker run \ + -it \ + --rm \ + --platform linux/arm64 \ + hamlib-runtime bash +``` + diff --git a/docker-build/README.docker b/docker-build/README.docker deleted file mode 100644 index 44a031344..000000000 --- a/docker-build/README.docker +++ /dev/null @@ -1,7 +0,0 @@ - -# Build, execute from the repository root -`docker buildx build --platform linux/amd64,linux/arm64 -t hamlib-runtime -f docker-build/Dockerfile .` - -# Run the hamlib-runtime -`docker run -it hamlib-runtime bash` - From bef2d13e4a8443ce32bba28116398a3edf156a45 Mon Sep 17 00:00:00 2001 From: Brandon Durepo Date: Sat, 21 Dec 2024 09:25:09 -0800 Subject: [PATCH 4/5] Added git and vim to the hamlib-base-image --- docker-build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-build/Dockerfile b/docker-build/Dockerfile index d5c490a73..cf3cdfe3e 100644 --- a/docker-build/Dockerfile +++ b/docker-build/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:latest AS hamlib-base-image ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" RUN apt-get update \ - && apt-get install -y build-essential automake libtool python3.6 \ + && apt-get install -y vim git build-essential automake libtool python3.6 \ && rm -rf /var/lib/apt/lists/* # Builder Image From db00197e6adcddd18a810f619d38ac04c87fbd69 Mon Sep 17 00:00:00 2001 From: Brandon Durepo Date: Sat, 21 Dec 2024 11:55:14 -0800 Subject: [PATCH 5/5] Added Python support --- docker-build/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-build/Dockerfile b/docker-build/Dockerfile index cf3cdfe3e..d92407f18 100644 --- a/docker-build/Dockerfile +++ b/docker-build/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:latest AS hamlib-base-image ENV DEBIAN_FRONTEND="noninteractive" TZ="Etc/UTC" RUN apt-get update \ - && apt-get install -y vim git build-essential automake libtool python3.6 \ + && apt-get install -y vim git build-essential automake libtool python-is-python3 \ && rm -rf /var/lib/apt/lists/* # Builder Image