Skip to content

Commit 49ee886

Browse files
authored
Rework archive image builds. (#1557)
Add annotations and labels to images. Move source tree manipulations out of docker. Use a bind mount to access the patched source from docker. Use a multistage build to minimize the image size. Move 1.9.0 build from jammy to noble.
1 parent 5d5799f commit 49ee886

17 files changed

+699
-238
lines changed

.github/workflows/docker.yml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_call:
66
inputs:
77
version:
8-
description: 'verison to archive'
8+
description: 'version to archive'
99
required: false
1010
default: dev
1111
type: string
@@ -17,7 +17,7 @@ on:
1717
workflow_dispatch:
1818
inputs:
1919
version:
20-
description: 'verison to archive'
20+
description: 'version to archive'
2121
required: true
2222
type: string
2323
latest:
@@ -33,25 +33,49 @@ jobs:
3333
env:
3434
docker_repository: ${{ case(github.repository == 'GPSBabel/gpsbabel', 'tsteven4/gpsbabel', 'tsteven4/testing') }}
3535
steps:
36+
- name: Compute tag
37+
id: compute
38+
run: |
39+
if [ "${{ inputs.version }}" == "dev" ]; then
40+
echo "tag=master" >> "$GITHUB_OUTPUT"
41+
else
42+
echo "tag=gpsbabel_$(echo ${{ inputs.version }} | tr . _)" >> "$GITHUB_OUTPUT"
43+
fi
44+
- name: Checkout
45+
uses: actions/checkout@v5
46+
with:
47+
ref: ${{ steps.compute.outputs.tag }}
48+
fetch-depth: 0
49+
- name: Update archive_images
50+
run: |
51+
git checkout ${{ github.sha }} -- tools/archive_images
52+
- name: Patch
53+
run: |
54+
patch=tools/archive_images/gpsbabel_$(echo ${{ inputs.version }} | tr . _).patch
55+
if [ -e "${patch}" ]; then
56+
echo "Applying patch ${patch}"
57+
git apply -v "${patch}"
58+
fi
3659
- name: Login to Docker Hub
3760
uses: docker/login-action@v4
3861
with:
3962
username: tsteven4
4063
password: ${{ secrets.DOCKERHUB_TOKEN }}
4164
- name: Set up Docker Buildx
4265
uses: docker/setup-buildx-action@v4
43-
- name: Build and export to Docker
66+
- name: Build and load
4467
uses: docker/build-push-action@v7
4568
with:
46-
context: "{{defaultContext}}:tools/archive_images"
47-
file: "Dockerfile_gpsbabel_${{ inputs.version }}"
69+
context: .
70+
file: ./tools/archive_images/Dockerfile_gpsbabel_${{ inputs.version }}
4871
load: true
4972
tags: "${{ env.docker_repository }}:test_${{ inputs.version }}"
5073
- name: Test
5174
run: |
5275
# tests failed before 1.6.0 (and repository structure was different)
5376
if [[ "${{ inputs.version }}" == "dev" || $(echo -e "${{ inputs.version }}\n1.6.0" | sort -V | head -n1) == "1.6.0" ]]; then
54-
docker run --rm -w /home/gpsbabel/gpsbabel-build -e PNAME=/usr/local/bin/gpsbabel "${{ env.docker_repository }}:test_${{ inputs.version }}" ./testo
77+
docker run --rm --volume ${{ github.workspace }}:/app "${{ env.docker_repository }}:test_${{ inputs.version }}" \
78+
/bin/bash -c 'PNAME=$(which gpsbabel) ./testo'
5579
fi
5680
- name: Docker Metadata
5781
id: meta
@@ -65,10 +89,13 @@ jobs:
6589
type=raw,value=${{ inputs.version }}
6690
type=raw,value=${{ inputs.version }}_{{date 'YYYYMMDD[T]HHmmss[Z]' tz='UTC'}}
6791
type=raw,value=latest,enable=${{ inputs.latest }}
92+
context: git
6893
- name: Build and push
6994
uses: docker/build-push-action@v7
7095
with:
71-
context: "{{defaultContext}}:tools/archive_images"
72-
file: "Dockerfile_gpsbabel_${{ inputs.version }}"
96+
context: .
97+
file: ./tools/archive_images/Dockerfile_gpsbabel_${{ inputs.version }}
7398
push: true
7499
tags: ${{ steps.meta.outputs.tags }}
100+
labels: ${{ steps.meta.outputs.labels }}
101+
annotations: ${{ steps.meta.outputs.annotations }}

tools/archive_images/Dockerfile_gpsbabel_1.10.0

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# this file is used to build the image gpsbabel_build_environment used by travis.
22

3-
FROM ubuntu:noble
4-
5-
LABEL maintainer="https://github.com/tsteven4"
6-
7-
WORKDIR /app
3+
FROM ubuntu:noble AS stage
84

95
# update environment.
106
ARG DEBIAN_FRONTEND=noninteractive
@@ -59,22 +55,59 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5955
&& locale-gen \
6056
&& locale -a
6157

62-
WORKDIR /home/gpsbabel
63-
64-
RUN git clone https://github.com/GPSBabel/gpsbabel.git gpsbabel-build\
65-
&& cd gpsbabel-build \
66-
&& git checkout gpsbabel_1_10_0 \
58+
RUN --mount=type=bind,target=/home/gpsbabel/gpsbabel-build,rw cd /home/gpsbabel/gpsbabel-build \
6759
&& rm -fr zlib \
6860
&& rm -fr shapelib \
6961
&& sed -i -e"/GB.SHA/i set(ENV{GITHUB_SHA} \"$(git log -1 --format=%h)\")" gbversion.cmake \
70-
&& mkdir bld \
71-
&& cd bld \
72-
&& cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt6 -DGPSBABEL_WITH_ZLIB=pkgconfig -DGPSBABEL_WITH_SHAPELIB=pkgconfig -DGPSBABEL_ENABLE_PCH=OFF .. \
73-
&& cmake --build . --target package_app \
74-
&& cmake --build . --target check \
75-
&& ln -s $(pwd)/gui/GPSBabelFE/gpsbabel /usr/local/bin \
76-
&& ln -s $(pwd)/gui/GPSBabelFE/gpsbabelfe /usr/local/bin
62+
&& cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake/Qt6 -DGPSBABEL_WITH_ZLIB=pkgconfig -DGPSBABEL_WITH_SHAPELIB=pkgconfig -B bld \
63+
&& cmake --build bld --target package_app \
64+
&& cmake --build bld --target check \
65+
&& mkdir -p /usr/local/cellar \
66+
&& cp -pr bld/gui/GPSBabelFE /usr/local/cellar \
67+
&& ln -s /usr/local/cellar/GPSBabelFE/gpsbabel /usr/local/bin \
68+
&& ln -s /usr/local/cellar/GPSBabelFE/gpsbabelfe /usr/local/bin \
69+
&& cp tools/archive_images/setup_user.sh /usr/local/bin
70+
71+
FROM ubuntu:noble
72+
73+
LABEL maintainer="https://github.com/tsteven4"
74+
75+
# update environment.
76+
ARG DEBIAN_FRONTEND=noninteractive
77+
RUN apt-get update && apt-get install -y --no-install-recommends \
78+
&& apt-get upgrade -y \
79+
&& rm -rf /var/lib/apt/lists/*
80+
81+
# the trick here is finding all the packages that we, and the plugins we
82+
# use need. Note we had to figure this out for snapcraft, but it
83+
# changes for different flavors of ubuntu.
84+
RUN apt-get update && apt-get install -y --no-install-recommends \
85+
ca-certificates \
86+
tzdata \
87+
libusb-1.0-0 \
88+
libudev1 \
89+
libshp4 \
90+
zlib1g \
91+
libqt6core6 \
92+
libqt6core5compat6 \
93+
libqt6gui6 \
94+
libqt6network6 \
95+
libqt6serialport6 \
96+
libqt6widgets6 \
97+
libqt6xml6 \
98+
libqt6webenginewidgets6 \
99+
libqt6webenginecore6 \
100+
libqt6webenginecore6-bin \
101+
qt6-translations-l10n \
102+
qt6-qpa-plugins \
103+
qt6-wayland \
104+
&& rm -rf /var/lib/apt/lists/*
105+
106+
COPY --from=stage /usr/local/cellar /usr/local/cellar
107+
COPY --from=stage /usr/local/bin/setup_user.sh /usr/local/bin
108+
109+
RUN ln -s /usr/local/cellar/GPSBabelFE/gpsbabel /usr/local/bin \
110+
&& ln -s /usr/local/cellar/GPSBabelFE/gpsbabelfe /usr/local/bin
77111

78-
COPY setup_user.sh /usr/local/bin
79112
USER ubuntu:ubuntu
80113
WORKDIR /app

tools/archive_images/Dockerfile_gpsbabel_1.5.0

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# this file is used to build the image gpsbabel_build_environment used by travis.
22

3-
FROM ubuntu:focal
4-
5-
LABEL maintainer="https://github.com/tsteven4"
6-
7-
WORKDIR /app
3+
FROM ubuntu:focal AS stage
84

95
# update environment.
106
ARG DEBIAN_FRONTEND=noninteractive
@@ -57,21 +53,55 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5753
&& locale-gen \
5854
&& locale -a
5955

60-
WORKDIR /home/gpsbabel
61-
62-
COPY gpsbabel_1_5_0.patch /home/gpsbabel
63-
64-
RUN git clone https://github.com/GPSBabel/gpsbabel.git gpsbabel-build\
65-
&& cd gpsbabel-build \
66-
&& git checkout gpsbabel_1_5_0 \
56+
RUN --mount=type=bind,target=/home/gpsbabel/gpsbabel-build,rw cd /home/gpsbabel/gpsbabel-build \
6757
&& cd gpsbabel \
68-
&& git apply /home/gpsbabel/gpsbabel_1_5_0.patch \
6958
&& rm -fr zlib \
7059
&& autoconf -f && ./configure --with-zlib=system && make -j 10 linux-gui \
71-
&& ln -s $(pwd)/gui/GPSBabel1.5.0/gpsbabel /usr/local/bin \
72-
&& ln -s $(pwd)/gui/GPSBabel1.5.0/gpsbabelfe /usr/local/bin
60+
&& mkdir -p /usr/local/cellar \
61+
&& cp -pr gui/GPSBabel1.5.0 /usr/local/cellar \
62+
&& ln -s /usr/local/cellar/GPSBabel1.5.0/gpsbabel /usr/local/bin \
63+
&& ln -s /usr/local/cellar/GPSBabel1.5.0/gpsbabelfe /usr/local/bin \
64+
&& cp ../tools/archive_images/setup_user.sh /usr/local/bin
65+
66+
FROM ubuntu:focal
67+
68+
LABEL maintainer="https://github.com/tsteven4"
69+
70+
# update environment.
71+
ARG DEBIAN_FRONTEND=noninteractive
72+
RUN apt-get update && apt-get install -y --no-install-recommends \
73+
&& apt-get upgrade -y \
74+
&& rm -rf /var/lib/apt/lists/*
75+
76+
# HINTS
77+
# apt-cache depends gpsbabel
78+
# apt-cache depends gpsbabel-gui
79+
# focal shipped gpsbabel 1.6.0 using webengine
80+
# note our early builds didn't use system shapelib (delete libshp2)
81+
# note our early builds used webkit instead of webengine (add libqt5webkit5, delete libqt5webenginewidgets5)
82+
RUN apt-get update && apt-get install -y --no-install-recommends \
83+
ca-certificates \
84+
libc6 \
85+
libgcc-s1 \
86+
libqt5core5a \
87+
libqt5gui5 \
88+
libqt5network5 \
89+
libqt5webchannel5 \
90+
libqt5webkit5 \
91+
libqt5widgets5 \
92+
libqt5xml5 \
93+
libshp2 \
94+
libstdc++6 \
95+
libusb-0.1-4 \
96+
zlib1g \
97+
&& rm -rf /var/lib/apt/lists/*
98+
99+
COPY --from=stage /usr/local/cellar /usr/local/cellar
100+
COPY --from=stage /usr/local/bin/setup_user.sh /usr/local/bin
101+
102+
RUN ln -s /usr/local/cellar/GPSBabel*/gpsbabel /usr/local/bin \
103+
&& ln -s /usr/local/cellar/GPSBabel*/gpsbabelfe /usr/local/bin
73104

74-
COPY setup_user.sh /usr/local/bin
75105
RUN useradd ubuntu -m -s /bin/bash
76106
USER ubuntu:ubuntu
77107
WORKDIR /app

tools/archive_images/Dockerfile_gpsbabel_1.5.1

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# this file is used to build the image gpsbabel_build_environment used by travis.
22

3-
FROM ubuntu:focal
4-
5-
LABEL maintainer="https://github.com/tsteven4"
6-
7-
WORKDIR /app
3+
FROM ubuntu:focal AS stage
84

95
# update environment.
106
ARG DEBIAN_FRONTEND=noninteractive
@@ -57,21 +53,55 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
5753
&& locale-gen \
5854
&& locale -a
5955

60-
WORKDIR /home/gpsbabel
61-
62-
COPY gpsbabel_1_5_1.patch /home/gpsbabel
63-
64-
RUN git clone https://github.com/GPSBabel/gpsbabel.git gpsbabel-build\
65-
&& cd gpsbabel-build \
66-
&& git checkout gpsbabel_1_5_1 \
56+
RUN --mount=type=bind,target=/home/gpsbabel/gpsbabel-build,rw cd /home/gpsbabel/gpsbabel-build \
6757
&& cd gpsbabel \
68-
&& git apply /home/gpsbabel/gpsbabel_1_5_1.patch \
6958
&& rm -fr zlib \
7059
&& autoconf -f && ./configure --with-zlib=system && make -j 10 linux-gui \
71-
&& ln -s $(pwd)/gui/GPSBabel1.5.1/gpsbabel /usr/local/bin \
72-
&& ln -s $(pwd)/gui/GPSBabel1.5.1/gpsbabelfe /usr/local/bin
60+
&& mkdir -p /usr/local/cellar \
61+
&& cp -pr gui/GPSBabel1.5.1 /usr/local/cellar \
62+
&& ln -s /usr/local/cellar/GPSBabel1.5.1/gpsbabel /usr/local/bin \
63+
&& ln -s /usr/local/cellar/GPSBabel1.5.1/gpsbabelfe /usr/local/bin \
64+
&& cp ../tools/archive_images/setup_user.sh /usr/local/bin
65+
66+
FROM ubuntu:focal
67+
68+
LABEL maintainer="https://github.com/tsteven4"
69+
70+
# update environment.
71+
ARG DEBIAN_FRONTEND=noninteractive
72+
RUN apt-get update && apt-get install -y --no-install-recommends \
73+
&& apt-get upgrade -y \
74+
&& rm -rf /var/lib/apt/lists/*
75+
76+
# HINTS
77+
# apt-cache depends gpsbabel
78+
# apt-cache depends gpsbabel-gui
79+
# focal shipped gpsbabel 1.6.0 using webengine
80+
# note our early builds didn't use system shapelib (delete libshp2)
81+
# note our early builds used webkit instead of webengine (add libqt5webkit5, delete libqt5webenginewidgets5)
82+
RUN apt-get update && apt-get install -y --no-install-recommends \
83+
ca-certificates \
84+
libc6 \
85+
libgcc-s1 \
86+
libqt5core5a \
87+
libqt5gui5 \
88+
libqt5network5 \
89+
libqt5webchannel5 \
90+
libqt5webkit5 \
91+
libqt5widgets5 \
92+
libqt5xml5 \
93+
libshp2 \
94+
libstdc++6 \
95+
libusb-0.1-4 \
96+
zlib1g \
97+
&& rm -rf /var/lib/apt/lists/*
98+
99+
COPY --from=stage /usr/local/cellar /usr/local/cellar
100+
COPY --from=stage /usr/local/bin/setup_user.sh /usr/local/bin
101+
102+
RUN ln -s /usr/local/cellar/GPSBabel*/gpsbabel /usr/local/bin \
103+
&& ln -s /usr/local/cellar/GPSBabel*/gpsbabelfe /usr/local/bin
73104

74-
COPY setup_user.sh /usr/local/bin
75105
RUN useradd ubuntu -m -s /bin/bash
76106
USER ubuntu:ubuntu
77107
WORKDIR /app

0 commit comments

Comments
 (0)