Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit 09fefac

Browse files
Merge pull request #7 from wilma-digital/main
[INFRA] add trixie to stack
2 parents 8d23c7c + 7f1b595 commit 09fefac

6 files changed

Lines changed: 268 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
version: [ 'bullseye', 'bookworm' ]
14+
version: [ 'bullseye', 'bookworm', 'trixie']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

.github/workflows/schedule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
version: [ 'bullseye', 'bookworm' ]
14+
version: [ 'bullseye', 'bookworm', 'trixie' ]
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v4

src/trixie/src/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM debian:trixie-slim
2+
3+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4+
ENV BASH_ENV=/etc/profile \
5+
DEBIAN_FRONTEND=noninteractive \
6+
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
7+
WORKDIR /tmp/
8+
9+
ARG CONTAINER_RUNTIME_REQUIREMENTS="less procps netcat ca-certificates iputils-ping iproute2 unzip"
10+
ARG CONTAINER_RUNTIME_REQUIREMENTS_EXTRA=""
11+
ARG CONTAINER_BUILD_REQUIREMENTS=""
12+
ARG CONTAINER_BUILD_REQUIREMENTS_EXTRA=""
13+
14+
COPY root /
15+
16+
# hadolint ignore=DL3008,DL3015
17+
RUN set -Eeu; \
18+
chmod 755 /usr/local/bin/{docker-layer-clean,docker-install-requirements,docker-package-download}; \
19+
echo "APT::Install-Recommends \"false\";" > /etc/apt/apt.conf.d/docker-disable-recommends; \
20+
echo "export PATH=\"${PATH}\"" > /etc/environment; \
21+
mkdir -p /usr/share/man/man1; \
22+
mkdir -p /usr/share/man/man7; \
23+
/usr/local/bin/docker-install-requirements; \
24+
sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf; \
25+
update-ca-certificates -f; \
26+
/usr/local/bin/docker-layer-clean
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit # Exit script when a command exits with non-zero status
4+
set -o errtrace # Exit on error inside any functions or sub-shells
5+
set -o nounset # Exit script on use of an undefined variable
6+
set -o pipefail # Return exit status of the last command in the pipe that failed
7+
8+
# ------------------------------------------------------------------------------
9+
# Displays a status message
10+
#
11+
# Arguments:
12+
# $* Status message to display
13+
# Returns:
14+
# Exit code
15+
# ------------------------------------------------------------------------------
16+
display_status_message() {
17+
local status=$*
18+
19+
echo "-----> ${status}"
20+
}
21+
22+
# ------------------------------------------------------------------------------
23+
# get apt package requirements from env vars
24+
#
25+
# Arguments:
26+
# $1 Filter prefix
27+
# $2 BUILD or Runtime
28+
# Returns:
29+
# string
30+
# ------------------------------------------------------------------------------
31+
get_requirements() {
32+
#printf "'%s'='%s'\n" "$n" "$v"
33+
while IFS='=' read -r -d '' n v; do
34+
if [[ "$n" == "${1^^}_${2^^}_REQUIREMENTS"* ]]; then
35+
echo "${v}"
36+
fi
37+
done < <(env -0)
38+
}
39+
40+
apt-get update -y || true
41+
42+
display_status_message "Installing runtime requirements"
43+
for REQUIREMENT in $(get_requirements "${1:-container}" "runtime"); do
44+
apt-get install -y "${REQUIREMENT}"
45+
done
46+
47+
display_status_message "Installing build requirements"
48+
for REQUIREMENT in $(get_requirements "${1:-container}" "build"); do
49+
if ! dpkg -l | grep -P "^ii(?:[\s]{2})${REQUIREMENT//=*}(:?\:.*)?(?:[\s]+).*(?:all|amd64).*$" > /dev/null 2>&1; then
50+
apt-get install -y "${REQUIREMENT}"
51+
apt-mark auto "${REQUIREMENT}"
52+
else
53+
echo "Package ${REQUIREMENT} already installed skipping automatic remove during cleanup."
54+
apt-get install -y "${REQUIREMENT}"
55+
fi
56+
done
57+
apt-get update -y || true
58+
display_status_message "Installing container requirements finished"
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit # Exit script when a command exits with non-zero status
4+
set -o errtrace # Exit on error inside any functions or sub-shells
5+
set -o nounset # Exit script on use of an undefined variable
6+
set -o pipefail # Return exit status of the last command in the pipe that failed
7+
8+
readonly EX_OK=0 # Successful termination
9+
readonly EX_UNKNOWN=1 # Unknown error occured
10+
11+
declare CLEANUP_LOG_FILES=true
12+
declare CLEANUP_TMP_FOLDERS=true
13+
declare CLEANUP_APT=true
14+
declare CLEANUP_PIP=true
15+
16+
# ------------------------------------------------------------------------------
17+
# Displays a error message and is able to terminate te script execution
18+
#
19+
# Arguments:
20+
# $1 Error message
21+
# $2 Exit code, script will continue execution when omitted
22+
# Returns:
23+
# None
24+
# ------------------------------------------------------------------------------
25+
display_error_message() {
26+
local status=${1}
27+
local exitcode=${2:-0}
28+
29+
echo >&2
30+
echo " ! ERROR: ${status}"
31+
echo >&2
32+
33+
if [[ ${exitcode} -ne 0 ]]; then
34+
exit "${exitcode}"
35+
fi
36+
}
37+
38+
# ------------------------------------------------------------------------------
39+
# Displays a notice
40+
#
41+
# Arguments:
42+
# $* Notice message to display
43+
# Returns:
44+
# Exit code
45+
# ------------------------------------------------------------------------------
46+
display_notice_message() {
47+
local status=$*
48+
49+
echo
50+
echo "NOTICE: ${status}"
51+
echo
52+
}
53+
54+
# ------------------------------------------------------------------------------
55+
# Displays a status message
56+
#
57+
# Arguments:
58+
# $* Status message to display
59+
# Returns:
60+
# Exit code
61+
# ------------------------------------------------------------------------------
62+
display_status_message() {
63+
local status=$*
64+
65+
echo "-----> ${status}"
66+
}
67+
68+
# ------------------------------------------------------------------------------
69+
# Docker build the image
70+
#
71+
# Arguments:
72+
# None
73+
# Returns:
74+
# Exit code
75+
# ------------------------------------------------------------------------------
76+
docker_clean() {
77+
display_status_message "Running Docker clean"
78+
79+
cd /
80+
81+
if [[ "${CLEANUP_LOG_FILES}" = true ]]; then
82+
find /var/log -type f -print0 | xargs -0 truncate -s0
83+
fi
84+
85+
if [[ "${CLEANUP_APT}" = true ]]; then
86+
apt-get autoremove --purge --yes --quiet;
87+
apt-get clean -y
88+
fi
89+
90+
if [[ "${CLEANUP_PIP}" = true && -d "${HOME}/.cache/pip" ]]; then
91+
rm -rf "${HOME}/.cache/pip"
92+
fi
93+
94+
if [[ "${CLEANUP_TMP_FOLDERS}" = true ]]; then
95+
find /tmp/ -mindepth 1 -maxdepth 1 -exec rm -rf {} +
96+
find /var/tmp/ -mindepth 1 -maxdepth 1 -exec rm -rf {} +
97+
fi
98+
99+
rm -rf /var/lib/apt/lists/*
100+
rm -rf /usr/share/doc/*
101+
rm -rf /usr/share/groff/*
102+
rm -rf /usr/share/info/*
103+
rm -rf /usr/share/linda/*
104+
rm -rf /usr/share/lintian/*
105+
rm -rf /usr/share/man/*/*
106+
107+
display_status_message 'Docker clean finished'
108+
109+
return "${EX_OK}"
110+
}
111+
112+
display_help () {
113+
local exit_code=${1:-${EX_OK}}
114+
local status=${2:-}
115+
116+
[[ -n "${status}" ]] && display_error_message "${status}"
117+
118+
cat << EOF
119+
Usage: /usr/local/bin/docker-layer-clean [options]
120+
Options:
121+
-h, Display this help and exit.
122+
-l, Do not truncate logfiles
123+
-p, Do not remove *-dev packages
124+
-a, Do not cleanup apt
125+
-t, Do not cleanup tmp folders
126+
-p, Do not cleanup python pip cache
127+
EOF
128+
129+
exit "${exit_code}"
130+
}
131+
132+
parse_cli_arguments() {
133+
local OPTIND o
134+
while getopts ":hlpat" o; do
135+
case "${o}" in
136+
l)
137+
CLEANUP_LOG_FILES=false
138+
;;
139+
t)
140+
CLEANUP_TMP_FOLDERS=false
141+
;;
142+
a)
143+
CLEANUP_APT=false
144+
;;
145+
p)
146+
CLEANUP_PIP=false
147+
;;
148+
h)
149+
display_help "${EX_OK}"
150+
;;
151+
:)
152+
display_help "${EX_UNKNOWN}" "Option -${OPTARG} requires an argument";
153+
;;
154+
\?)
155+
display_help "${EX_UNKNOWN}" "Invalid option: -${OPTARG}";
156+
;;
157+
*)
158+
display_help "${EX_UNKNOWN}" "Missing required arguments.";
159+
;;
160+
esac
161+
done
162+
shift $((OPTIND-1))
163+
}
164+
165+
# ==============================================================================
166+
# RUN LOGIC
167+
# ------------------------------------------------------------------------------
168+
main() {
169+
# Parse input
170+
parse_cli_arguments "$@"
171+
docker_clean
172+
exit "${EX_OK}"
173+
}
174+
175+
# Bootstrap
176+
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
177+
# Direct call to file
178+
main "$@"
179+
fi # Else file is included from another script
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
curl --connect-timeout 5 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 40 -s -S -L "$@"

0 commit comments

Comments
 (0)