Skip to content

Commit 932368c

Browse files
authored
Fix broken Dockerfile and minor improvements (#439)
* Fix broken Dockerfile and minor improvements This fixes an issue introduced by a past PR (#432). It uses an argument that doesn't exist ("STACKABLE_USER_NAME"). In the course of diagnosing that I stumbled across a few inconsistencies with our "docker-images" Dockerfiles which I am addressing here as well. - Updates the Helm version used (not caught by Renovate yet) - Sets a build timeout for the build & package phase to two hours (down from the default of 6) - Adds the dnf.conf file - Adds convenience utilities - Adds a few common aliases and a better prompt * Add a small README
1 parent 918b646 commit 932368c

File tree

2 files changed

+71
-9
lines changed

2 files changed

+71
-9
lines changed

template/.github/workflows/build.yml.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ jobs:
265265
- name: Set up Helm
266266
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
267267
with:
268-
version: v3.13.3
268+
version: v3.16.1
269269
- name: Set up cargo
270270
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a
271271
with:
@@ -310,6 +310,7 @@ jobs:
310310
matrix:
311311
runner: ["ubuntu-latest", "ubicloud-standard-8-arm"]
312312
runs-on: ${{ matrix.runner }}
313+
timeout-minutes: 120
313314
permissions:
314315
id-token: write
315316
env:

template/docker/Dockerfile.j2

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,55 @@ LABEL io.openshift.tags="ubi9,stackable,sdp,{[ operator.product_string }]"
6666
LABEL io.k8s.description="Deploy and manage {[ operator.pretty_string }] clusters."
6767
LABEL io.k8s.display-name="Stackable Operator for {[ operator.pretty_string }]"
6868

69+
COPY <<EOF /etc/dnf/dnf.conf
70+
[main]
71+
install_weak_deps=0
72+
assumeyes=True
73+
tsflags=nodocs
74+
EOF
75+
6976
RUN <<EOF
70-
# Update image and install kerberos client libraries
71-
# install_weak_deps in microdnf does not support the literal "False" as dnf does
72-
# https://github.com/rpm-software-management/microdnf/blob/a600c62f29262d71a6259b70dc220df65a2ab9b5/dnf/dnf-main.c#L176-L189
77+
# Update image and install kerberos client libraries as well as some other utilities
7378
microdnf update
79+
80+
# **iputils**
81+
# To make debugging easier, includes things like ping
82+
# Added 2024-03: We cannot find any vulnerabilities in the past years
83+
# https://github.com/iputils/iputils
84+
#
85+
# **less**
86+
# To make debugging easier
87+
# Added 2024-03: less has seen three vulnerabilities between 2004 and 2022 which is a risk we're willing to accept for the added convenience
88+
# https://nvd.nist.gov/vuln/search/results?form_type=Advanced&results_type=overview&search_type=all&isCpeNameSearch=false&cpe_vendor=cpe%3A%2F%3Agnu&cpe_product=cpe%3A%2F%3A%3Aless
89+
# cpe:2.3:a:gnu:less:*:*:*:*:*:*:*:*
90+
#
91+
# **nano**
92+
# To make debugging and changing things easier
93+
# Added 2024-03: We checked and it has not seen any vulnerabilities since 2010 (as of 2024-03) we decided to accept it into our base image
94+
# https://nvd.nist.gov/vuln/search/results?form_type=Advanced&results_type=overview&query=cpe%3A2.3%3Aa%3Agnu%3Anano&search_type=all&isCpeNameSearch=false
95+
# cpe:2.3:a:gnu:nano:*:*:*:*:*:*:*:*
96+
#
97+
# **tar**
98+
# To enable kubectl cp
99+
# Added 2024-03: We checked and it has seen eight vulnerabilities since 2001, mostly minor and it's not in executable path so we decided to accept the risk
100+
# https://nvd.nist.gov/vuln/search/results?adv_search=true&isCpeNameSearch=true&query=cpe%3A2.3%3Aa%3Agnu%3Atar%3A-%3A*%3A*%3A*%3A*%3A*%3A*%3A*
101+
# cpe:2.3:a:gnu:tar:-:*:*:*:*:*:*:*
74102
# NOTE (@NickLarsenNZ): Maybe we should consider pinning package versions?
75103
# hadolint ignore=DL3041
76-
microdnf install -y \
104+
microdnf install \
105+
iputils \
77106
krb5-libs \
107+
less \
78108
libkadm5 \
79-
shadow-utils
109+
nano \
110+
shadow-utils \
111+
tar
80112

81-
groupadd --gid ${STACKABLE_USER_GID} --system ${STACKABLE_USER_NAME}
113+
groupadd --gid ${STACKABLE_USER_GID} --system stackable
82114
# The --no-log-init is required to work around a bug/problem in Go/Docker when very large UIDs are used
83115
# See https://github.com/moby/moby/issues/5419#issuecomment-41478290 for more context
84116
# Making this a system user prevents a mail dir from being created, expiry of passwords etc. but it will warn:
85-
# useradd warning: stackable's uid 1000 is greater than SYS_UID_MAX 999
117+
# useradd warning: stackable's uid 782252253 is greater than SYS_UID_MAX 999
86118
# We can safely ignore this warning, to get rid of the warning we could change /etc/login.defs but that does not seem worth it
87119
# We'll leave the home directory hardcoded to /stackable because I don't want to deal with which chars might be valid and which might not in user name vs. directory
88120
useradd \
@@ -96,11 +128,40 @@ useradd \
96128
microdnf remove shadow-utils
97129
microdnf clean all
98130
rm -rf /var/cache/yum
131+
132+
###
133+
### Make shell usage in our containers "nicer"
134+
###
135+
{
136+
echo "alias ll='ls -alF --color=auto'"
137+
echo "alias ls='ls --color=auto'"
138+
echo "alias ..='cd ..'"
139+
echo "export PS1='\u@\[\e[36m\]\H\[\e[m\] \[\e[32m\]\$(pwd)\[\e[m\] \\$ '"
140+
} >> /stackable/.bashrc
141+
142+
echo -e "if [ -f ~/.bashrc ]; then\n\tsource ~/.bashrc\nfi" >> /stackable/.profile
143+
144+
chown ${STACKABLE_USER_UID}:0 /stackable/.bashrc
145+
chown ${STACKABLE_USER_UID}:0 /stackable/.profile
146+
147+
# All files and folders owned by root to support running as arbitrary users
148+
# This is best practice as all container users will belong to the root group (0)
149+
# This is not very relevant for the operator images but this makes it consistent with `docker-images`
150+
chown -R ${STACKABLE_USER_UID}:0 /stackable
151+
chmod -R g=u /stackable
152+
EOF
153+
154+
COPY <<EOF /README.md
155+
# Stackable Operator for {[ operator.pretty_string }]
156+
157+
* This image contains version ${VERSION} of the operator.
158+
* The operator binary can be found in `/usr/local/bin`
159+
* It is licensed under the OSL-3.0 - the full text can be found in `/licenses/LICENSE`
99160
EOF
100161
101162
COPY LICENSE /licenses/LICENSE
102163
103-
COPY --from=builder /app/* /usr/local/bin/
164+
COPY --from=builder --chown=${STACKABLE_USER_UID}:0 /app/* /usr/local/bin/
104165
105166
{[% if operator.include_productconfig is undefined or operator.include_productconfig == true %}]
106167
COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.name }]/config-spec/properties.yaml

0 commit comments

Comments
 (0)