Skip to content

Commit 5012d48

Browse files
authored
Gitlab runner container pr 1.x (#28)
* Adding a build for a prebuilt CI image. * Adding the docker SSH entrypoint script. * Updating container image name. * Making apt handling more robust. * Moving the CI container code to just be documentation.
1 parent 24a5cfe commit 5012d48

File tree

4 files changed

+81
-19
lines changed

4 files changed

+81
-19
lines changed

docker-images/controller-ci/Dockerfile

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
1-
# GitLab Runner controller based on
1+
# This Dockerfile is a mix of ce-dev's controller image
2+
# https://github.com/codeenigma/ce-dev/tree/1.x/docker-images/controller
3+
#
4+
# And a GitLab Runner controller based on
25
# https://gitlab.com/tmaczukin-test-projects/fargate-driver-debian/-/blob/master/Dockerfile
3-
FROM codeenigma/ce-dev-controller-1.x:latest
6+
7+
# Prepare the container
8+
9+
FROM codeenigma/ce-dev-1.x:latest
10+
11+
RUN \
12+
set -x && \
13+
export DEBIAN_FRONTEND=noninteractive && \
14+
apt-get update && \
15+
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confnew" && \
16+
apt-get install -y -o Dpkg::Options::="--force-confnew" \
17+
git ca-certificates git-lfs && \
18+
apt-get clean && \
19+
pip3 install ansible boto3 && \
20+
git lfs install --skip-repo && \
21+
update-alternatives --install /usr/bin/python python /usr/bin/python3 1 && \
22+
rm -rf \
23+
/var/lib/apt/lists/* \
24+
/var/log/* \
25+
/tmp/*
26+
27+
28+
RUN su - ce-dev -c "git clone --branch 1.x https://github.com/codeenigma/ce-provision.git /home/ce-dev/ce-provision"
29+
30+
COPY ./provision.yml /home/ce-dev/ce-provision/provision.yml
31+
32+
RUN \
33+
set -x && \
34+
export DEBIAN_FRONTEND=noninteractive && \
35+
apt-get update && \
36+
su - ce-dev -c "/usr/local/bin/ansible-playbook /home/ce-dev/ce-provision/provision.yml" && \
37+
rm /home/ce-dev/ce-provision/provision.yml && \
38+
apt-get clean && \
39+
rm -rf \
40+
/var/lib/apt/lists/* \
41+
/var/log/* \
42+
/tmp/*
43+
44+
# Install GitLab Runner and requirements
445

546
# ---------------------------------------------------------------------
647
# Install https://github.com/krallin/tini - a very small 'init' process
@@ -25,15 +66,6 @@ RUN curl -Lo /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.ama
2566
# like that.
2667
gitlab-runner --version
2768

28-
29-
RUN set -x && \
30-
export DEBIAN_FRONTEND=noninteractive && \
31-
apt-get update && \
32-
apt-get dist-upgrade -y -o Dpkg::Options::="--force-confnew" && \
33-
apt-get install -y ca-certificates git-lfs && \
34-
apt-get clean && \
35-
git lfs install --skip-repo
36-
3769
# ---------------------------------------------------------------------------------------------------
3870
# Execute a startup script.
3971
# https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
controller-ci
2+
=============
3+
4+
This is simply an EXAMPLE for provisioning a controller for running ce-provision in a container with GitLab CI.
5+
6+
Every organisation wanting to run ce-provision in a container must necessarily make their own container image which incorporates their own version of ce-provision-config and installs the dependencies for their choice of CI. There can be no such thing as a "generic" CI container because it needs to contain secrets and it needs to be tailored to the CI product.
7+
8+
As such any generated CI container *must* be private in the container registry, never make them public.
9+
10+
The Dockerfile within is a mix of ce-dev's controller image:
11+
* https://github.com/codeenigma/ce-dev/tree/1.x/docker-images/controller
12+
13+
And a GitLab Runner controller based on this project:
14+
* https://gitlab.com/tmaczukin-test-projects/fargate-driver-debian/-/blob/master/Dockerfile
15+
16+
You can build this container to see how it works, but it will not work with your infra because it currently incorporates an example ce-provision-config repo.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- hosts: localhost
3+
become: yes
4+
vars:
5+
- _domain_name: ci.example.com
6+
- _ce_provision_build_tmp_dir: /tmp
7+
- _ce_provision_data_dir: /tmp
8+
- is_local: yes
9+
- _env_type: utility
10+
- ce_provision:
11+
own_repository: https://github.com/codeenigma/ce-provision.git
12+
own_repository_branch: 1.x
13+
own_repository_skip_checkout: false
14+
config_repository: https://github.com/codeenigma/ce-dev-ce-provision-config.git
15+
config_repository_branch: 1.x
16+
config_repository_skip_checkout: false
17+
username: ce-dev
18+
local_dir: /home/ce-dev/ce-provision
19+
groups: []
20+
galaxy_custom_requirements_file: ""
21+
roles:
22+
- ce_provision

docker-images/export.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ if [ "$2" = "--push" ]; then
4545
docker image push "codeenigma/ce-dev-controller-1.x:$1"
4646
fi
4747

48-
# Build controller image for CI.
49-
echo "Building controller image for CI"
50-
docker image build --compress "--label=ce-dev-controller-ci-1.x:$1" --no-cache=true -t "codeenigma/ce-dev-controller-ci-1.x:$1" "$OWN_DIR/controller-ci" || exit 1
51-
if [ "$2" = "--push" ]; then
52-
echo "Publishing the image with docker image push codeenigma/ce-dev-controller-ci-1.x:$1"
53-
docker image push "codeenigma/ce-dev-controller-ci-1.x:$1"
54-
fi
55-
5648
# Build dind image.
5749
# echo "Building dind image"
5850
# sudo docker image build --compress "--label=ce-dev-dind-1.x:$1" --no-cache=true -t "codeenigma/ce-dev-dind-1.x:$1" "$OWN_DIR/dind" || exit 1

0 commit comments

Comments
 (0)