@@ -6,42 +6,38 @@ SHELL ["/bin/bash", "-c"]
66ARG TIMESTAMP
77RUN echo "Image built at ${TIMESTAMP}" > /etc/azldev_scenario_testing_timestamp
88
9- ARG USER_CONFIG
9+ ARG UID
10+ ARG GID
1011ARG WORK_DIR
1112
12- ENV USER_CONFIG=${USER_CONFIG}
13+ ENV UID=${UID}
14+ ENV GID=${GID}
1315
1416LABEL name="azldev_scenario_testing"
1517
16- # Install dependencies
17- # * We requires shadow-utils to be able to manage users and groups
18+ # Install early dependencies
19+ # * We require shadow-utils to be able to manage users and groups
20+ RUN tdnf -y install shadow-utils
21+
22+ # Create mock group and test user up-front, using the same UID and GID as the host's user so it lines up.
23+ RUN groupadd -f -g "${GID}" mock && \
24+ useradd -u "${UID}" -g "${GID}" -m testuser && \
25+ mkdir -p /etc/sudoers.d && \
26+ echo "testuser ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/testuser
27+
28+ # Install additional dependencies
1829# * We require ca-certificates to be able to interact with standard https endpoints
1930# * We require mock to build packages
2031# * We require sudo to run commands as root after dropping to test user
2132RUN tdnf -y install \
22- shadow-utils \
2333 ca-certificates \
2434 mock \
2535 sudo
2636
27- # Set up the default user (named "testuser") with the UID and GID we were given.
28- #
29- # NOTE: The <<< syntax requires use of bash (instead of /bin/sh), hence the SHELL directive above.
30- RUN groupadd -f -g "$(cut -d: -f2 <<<" ${USER_CONFIG}")" testuser && \
31- useradd -u "$(cut -d: -f1 <<<" ${USER_CONFIG}")" \
32- -g "$(cut -d: -f2 <<<" ${USER_CONFIG}")" \
33- -m \
34- testuser && \
35- echo "testuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/testuser
36-
37- # Add the user to the 'mock' group
38- RUN usermod -aG mock testuser && \
39- usermod -aG root testuser
40-
4137COPY entrypoint.sh /usr/local/bin/entrypoint.sh
4238
4339# Set the default user
44- USER ${USER_CONFIG}
40+ USER testuser:mock
4541
4642# Switch to the well-known work directory that the test infrastructure will
4743# copy files into.
0 commit comments