Skip to content

Commit 7fee2ef

Browse files
authored
added testing environment container (#2)
* added testing environment container * updated testing environment to have systemd and ssh server * added test admin to sudo group and fixed test environment container not building
1 parent 47b86ac commit 7fee2ef

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build and push testing-environment Docker image
2+
on:
3+
push:
4+
tags:
5+
- 'testing-environment-*'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Get release version
13+
id: get_version
14+
run: echo RELEASE_VERSION=$(echo ${GITHUB_REF:25}) >> $GITHUB_ENV
15+
- name: Build and push Docker image
16+
uses: docker/build-push-action@v1
17+
with:
18+
repository: wuvt/testing-environment
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_PASSWORD }}
21+
tags: latest,${{ env.RELEASE_VERSION }}
22+
path: testing-environment
23+
add_git_labels: true
24+
- name: Build and push Docker image to GitHub Container Registry
25+
uses: docker/build-push-action@v1
26+
with:
27+
repository: wuvt/testing-environment
28+
username: wuvt
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
registry: ghcr.io
31+
tags: latest,${{ env.RELEASE_VERSION }}
32+
path: testing-environment
33+
add_git_labels: true

testing-environment/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu:24.04
2+
LABEL maintainer="WUVT IT"
3+
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
6+
# Install dependencies.
7+
RUN apt-get update \
8+
&& apt-get install -y --no-install-recommends \
9+
software-properties-common \
10+
rsyslog systemd systemd-cron sudo iproute2 \
11+
openssh-server \
12+
&& apt-get clean \
13+
&& rm -Rf /var/lib/apt/lists/* \
14+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man
15+
RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf
16+
17+
COPY initctl_faker .
18+
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl
19+
20+
# Remove unnecessary getty and udev targets that result in high CPU usage when using
21+
# multiple containers with Molecule (https://github.com/ansible/molecule/issues/1104)
22+
RUN rm -f /lib/systemd/system/systemd*udev* \
23+
&& rm -f /lib/systemd/system/getty.target
24+
25+
RUN useradd -m tadmin -p '$1$BGGb.rYO$FoQmsTiSsKXPMqcm9uvlP1' -s /bin/bash
26+
RUN usermod -aG sudo tadmin
27+
28+
VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]
29+
EXPOSE 22
30+
CMD ["/lib/systemd/systemd"]

testing-environment/initctl_faker

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
ALIAS_CMD="$(echo ""$0"" | sed -e 's?/sbin/??')"
3+
4+
case "$ALIAS_CMD" in
5+
start|stop|restart|reload|status)
6+
exec service $1 $ALIAS_CMD
7+
;;
8+
esac
9+
10+
case "$1" in
11+
list )
12+
exec service --status-all
13+
;;
14+
reload-configuration )
15+
exec service $2 restart
16+
;;
17+
start|stop|restart|reload|status)
18+
exec service $2 $1
19+
;;
20+
\?)
21+
exit 0
22+
;;
23+
esac

0 commit comments

Comments
 (0)