Skip to content

Commit bc27333

Browse files
feat: switch to Alpine base image and update package installation (#214)
Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 0b42c7c commit bc27333

7 files changed

Lines changed: 96 additions & 45 deletions

File tree

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
!LICENSE
77
!README.md
88
!entrypoint.sh
9-
!pip
9+
!alpine-packages.txt

Dockerfile

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
1-
FROM ubuntu:questing-20251217
2-
3-
# Disable interactive mode
4-
ENV DEBIAN_FRONTEND=noninteractive
1+
FROM alpine:3.23.4
52

63
# Copy all needed files
74
COPY entrypoint.sh /
5+
COPY alpine-packages.txt /tmp/alpine-packages.txt
86

97
# Install needed packages
10-
SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
11-
# hadolint ignore=DL3008
12-
RUN chmod +x /entrypoint.sh ;\
13-
apt-get update -y ;\
14-
apt-get install --no-install-recommends -y \
15-
gpg-agent \
16-
software-properties-common ;\
17-
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections ;\
18-
add-apt-repository ppa:git-core/ppa ;\
19-
apt-get update -y ;\
20-
apt-get install --no-install-recommends -y \
21-
git ;\
22-
# Install git-lfs without post-install configuration to avoid dpkg errors \
23-
apt-get download git-lfs ;\
24-
dpkg --unpack git-lfs*.deb ;\
25-
rm -f /var/lib/dpkg/info/git-lfs.postinst ;\
26-
dpkg --configure git-lfs ;\
27-
apt-get install -f --no-install-recommends -y ;\
28-
rm git-lfs*.deb ;\
29-
apt-get clean ;\
30-
rm -rf /var/lib/apt/lists/*
8+
SHELL ["/bin/sh", "-euxo", "pipefail", "-c"]
9+
# hadolint ignore=DL3018
10+
RUN set -eux; \
11+
xargs -r apk add --no-cache < /tmp/alpine-packages.txt; \
12+
chmod +x /entrypoint.sh; \
13+
git --version; \
14+
git-lfs version; \
15+
rm -rf /var/cache/*; \
16+
rm -rf /root/.cache/*; \
17+
rm -rf /tmp/*
3118

3219
# Finish up
3320
WORKDIR /github/workspace

Taskfile.cicd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ tasks:
4444
- task: scripts:lint:yamllint
4545

4646
dependency:update:
47-
desc: 'No-op: no dedicated dependency updater configured for this profile'
47+
desc: Update repository dependencies not covered by Dependabot
4848
cmds:
49-
- task: scripts:dependency:update
49+
- task: scripts:packages:update
5050

5151
version:set:
5252
desc: Update version in README.md and action.yml

Taskfile.scripts.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ tasks:
7575
fi
7676
7777
dependency:update:
78-
desc: 'No-op: no dedicated dependency updater configured for this profile'
78+
desc: Update dependency metadata for this repository
7979
cmds:
80-
- |
81-
echo "INFO: No dedicated dependency updater configured for this repository profile."
82-
echo "INFO: Dependabot handles GitHub Actions and package metadata updates."
83-
echo "INFO: Keep this task as a safe no-op until a repo-specific dependency updater is defined."
80+
- task: packages:update
8481

8582
version:get:
8683
desc: Get current version
@@ -255,7 +252,22 @@ tasks:
255252
exit 0
256253
fi
257254
258-
base_image="$(sed -nE 's/^FROM[[:space:]]+([^[:space:]]+).*/\1/p' Dockerfile | head -1)"
255+
base_image="$(awk '
256+
toupper($1) == "FROM" {
257+
i = 2
258+
while (i <= NF && $i ~ /^--/) {
259+
i++
260+
}
261+
if (i <= NF) {
262+
image = $i
263+
}
264+
}
265+
END {
266+
if (image != "") {
267+
print image
268+
}
269+
}
270+
' Dockerfile)"
259271
if [ -z "$base_image" ]; then
260272
echo "INFO: Could not resolve base image; nothing to update"
261273
exit 0

alpine-packages.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bash~=5.3
2+
git~=2.52
3+
git-lfs~=3.7

entrypoint.sh

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,60 @@ if [[ "${REPOSITORY_PATH}" == /* ]]; then
3838
exit 1
3939
fi
4040

41-
WORKSPACE_DIR="$(realpath -m "${GITHUB_WORKSPACE}")"
42-
REPO_DIR="$(realpath -m "${GITHUB_WORKSPACE}/${REPOSITORY_PATH}")"
41+
if [[ -z "${GITHUB_WORKSPACE}" || ! -d "${GITHUB_WORKSPACE}" ]]; then
42+
echo "[ERROR] GITHUB_WORKSPACE must point to an existing directory."
43+
exit 1
44+
fi
45+
46+
normalize_relative_path() {
47+
local path part normalized
48+
local -a parts stack
49+
50+
path="${1:-.}"
51+
IFS='/' read -r -a parts <<< "${path}"
52+
stack=()
53+
54+
for part in "${parts[@]}"; do
55+
case "${part}" in
56+
""|".")
57+
;;
58+
"..")
59+
if (( ${#stack[@]} > 0 )) && [[ "${stack[-1]}" != ".." ]]; then
60+
unset 'stack[-1]'
61+
else
62+
stack+=("..")
63+
fi
64+
;;
65+
*)
66+
stack+=("${part}")
67+
;;
68+
esac
69+
done
70+
71+
if (( ${#stack[@]} == 0 )); then
72+
printf '.'
73+
return
74+
fi
75+
76+
normalized="${stack[0]}"
77+
for part in "${stack[@]:1}"; do
78+
normalized+="/${part}"
79+
done
80+
printf '%s' "${normalized}"
81+
}
82+
83+
WORKSPACE_DIR="$(cd "${GITHUB_WORKSPACE}" && pwd -P)"
84+
NORMALIZED_REPOSITORY_PATH="$(normalize_relative_path "${REPOSITORY_PATH}")"
85+
if [[ "${NORMALIZED_REPOSITORY_PATH}" == ".." || "${NORMALIZED_REPOSITORY_PATH}" == ../* ]]; then
86+
echo "[ERROR] Input 'repository_path' resolves outside GITHUB_WORKSPACE."
87+
exit 1
88+
fi
89+
90+
if [[ "${NORMALIZED_REPOSITORY_PATH}" == "." ]]; then
91+
REPO_DIR="${WORKSPACE_DIR}"
92+
else
93+
REPO_DIR="${WORKSPACE_DIR}/${NORMALIZED_REPOSITORY_PATH}"
94+
fi
4395
if [[ "${REPO_DIR}" != "${WORKSPACE_DIR}" && "${REPO_DIR}" != "${WORKSPACE_DIR}"/* ]]; then
4496
echo "[ERROR] Input 'repository_path' resolves outside GITHUB_WORKSPACE."
4597
exit 1

tests/docker/local-image.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ commandTests:
44
- name: OS version check
55
command: cat
66
args: [/etc/os-release]
7-
expectedOutput: [VERSION_ID="25\.10"]
7+
expectedOutput: [VERSION_ID=3\.23]
88

99
- name: Required tools installed
1010
command: bash
1111
args:
1212
- -lc
1313
- command -v bash >/dev/null 2>&1 && command -v git >/dev/null 2>&1 && command -v git-lfs >/dev/null 2>&1
1414

15-
- name: Apt cache cleaned
15+
- name: Temporary and APK cache cleaned
1616
command: bash
1717
args:
1818
- -lc
19-
- test ! -d /var/lib/apt/lists || test -z "$(find /var/lib/apt/lists -mindepth 1 -maxdepth 1 2>/dev/null)"
20-
21-
- name: Temporary apt artifacts removed
22-
command: bash
23-
args:
24-
- -lc
25-
- test ! -e /git-lfs*.deb
19+
- >-
20+
test ! -f /tmp/alpine-packages.txt &&
21+
(test ! -d /var/cache/apk || test -z "$(find /var/cache/apk -mindepth 1 -maxdepth 1 2>/dev/null)") &&
22+
(test ! -d /root/.cache || test -z "$(find /root/.cache -mindepth 1 -maxdepth 1 2>/dev/null)")
2623
2724
- name: Entrypoint handles default repository path
2825
command: bash

0 commit comments

Comments
 (0)