-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Christian Berendt <[email protected]>
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
ARG PYTHON_VERSION=3.12 | ||
FROM python:${PYTHON_VERSION}-slim-bookworm as builder | ||
|
||
ARG USER_ID=45000 | ||
ARG GROUP_ID=45000 | ||
ARG GROUP_ID_DOCKER=999 | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
# hadolint ignore=DL3003 | ||
RUN <<EOF | ||
# add user | ||
groupadd -g "$GROUP_ID" dragon | ||
groupadd -g "$GROUP_ID_DOCKER" docker | ||
useradd -l -g dragon -G docker -u "$USER_ID" -m -d /ansible dragon | ||
|
||
# create required directories | ||
mkdir -p \ | ||
/ansible \ | ||
/interface \ | ||
/share | ||
|
||
# set correct permssions | ||
chown -R dragon: /ansible /share /interface | ||
EOF | ||
|
||
USER dragon | ||
|
||
ARG PYTHON_VERSION=3.12 | ||
FROM python:${PYTHON_VERSION}-slim-bookworm | ||
|
||
COPY --link --from=builder / / | ||
USER dragon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Containerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
- name: Build osism-kubernetes image | ||
hosts: all | ||
|
||
environment: | ||
registry: "{{ docker_registry | default('osism.harbor.regio.digital') }}" | ||
repository: "{{ docker_namespace | default('osism') }}/osism-kubernetes" | ||
version: "{{ zuul['tag'] | default('latest') }}" | ||
|
||
tasks: | ||
- name: Log into registry | ||
community.docker.docker_login: | ||
registry_url: "{{ docker_registry }}" | ||
username: "{{ secret.DOCKER_USERNAME }}" | ||
password: "{{ secret.DOCKER_PASSWORD }}" | ||
when: push_image | default(false) | bool | ||
no_log: true | ||
|
||
- name: Run build script | ||
ansible.builtin.shell: | ||
executable: /bin/bash | ||
chdir: "{{ zuul.project.src_dir | default('.') }}" | ||
cmd: | | ||
set -e | ||
set -o pipefail | ||
set -x | ||
# This is a way to use this job also in other repositories | ||
# (osism/cfg-generics, osism/defaults, ..). The assumption | ||
# is that if no Containerfile is available, the job was executed | ||
# from one of the other repositories. There are probably more | ||
# elegant ways to solve this, but it is good enough for now. | ||
if [[ ! -e Containerfile ]]; then | ||
git clone https://github.com/osism/container-image-osism-kubernetes.git container-image | ||
pushd container-image | ||
fi | ||
created=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
revision=$(git rev-parse --short HEAD) | ||
if [[ -n $registry ]]; then | ||
repository="$registry/$repository" | ||
fi | ||
docker buildx build \ | ||
--build-arg "VERSION=$version" \ | ||
--label "org.opencontainers.image.created=$created" \ | ||
--label "org.opencontainers.image.documentation=https://osism.tech/docs/" \ | ||
--label "org.opencontainers.image.licenses=ASL 2.0" \ | ||
--label "org.opencontainers.image.revision=$revision" \ | ||
--label "org.opencontainers.image.source=https://github.com/osism/container-image-osism-kubernetes" \ | ||
--label "org.opencontainers.image.title=osism-kubernetes" \ | ||
--label "org.opencontainers.image.url=https://quay.io/organization/osism" \ | ||
--label "org.opencontainers.image.vendor=OSISM GmbH" \ | ||
--label "org.opencontainers.image.version=$version" \ | ||
--load \ | ||
--tag "$revision" \ | ||
. # <-- there is a dot | ||
changed_when: true | ||
|
||
- name: Run push script | ||
ansible.builtin.shell: | ||
executable: /bin/bash | ||
chdir: "{{ zuul.project.src_dir | default('.') }}" | ||
cmd: | | ||
set -e | ||
set -o pipefail | ||
set -x | ||
# If the way described above is used, we must first change to | ||
# the container-image directory to obtain the correct revision. | ||
if [[ ! -e Containerfile ]]; then | ||
pushd container-image | ||
fi | ||
revision=$(git rev-parse --short HEAD) | ||
if [[ -n $registry ]]; then | ||
repository="$registry/$repository" | ||
fi | ||
docker tag "$revision" "$repository:$version" | ||
docker push "$repository:$version" | ||
when: push_image | default(false) | bool | ||
changed_when: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: Run preparations | ||
hosts: all | ||
|
||
tasks: | ||
- name: Install required packages | ||
become: true | ||
ansible.builtin.apt: | ||
name: | ||
- python3-docker | ||
- python3-requests | ||
|
||
roles: | ||
- ensure-docker |