Commit c26d8461 authored by mh's avatar mh
Browse files

initial release of the container build

parents
Pipeline #4916 failed with stage
in 13 seconds
gitlab-deps
---
build_image:
stage: build
image: $CI_REGISTRY/immerda/container-images/buildah/centos:8
tags:
- buildah
script:
- ./build.sh
FROM registry.code.immerda.ch/immerda/container-images/base/centos:8
ENV NAME=gitlab-deps VERSION=0 ARCH=x86_64
LABEL name="$NAME" \
version="$VERSION" \
architecture="$ARCH" \
usage="podman run -p 3535 -v $(pwd)/data:/var/lib/gitlab-deps:rw,Z -v $(pwd)/token:/secrets/gitlab-token:ro,Z -e PROJECT_REGEXP='^immerda/.*' -e GITLAB_URL=https://code.immerda.ch -e GITLAB_TOKEN_FILE=/secrets/gitlab-token --userns=keep-id -it gitlab-deps" \
summary="Provides a gitlab CI build orchestration toolkit." \
maintainer="immerda admin team <admin@immerda.ch>"
COPY gitlab-deps /tmp/gitlab-deps
RUN dnf install -y python3-gitlab python3-cheroot python3-flask diffutils && \
cd /tmp/gitlab-deps && python3 setup.py install && \
mkdir /var/lib/gitlab-deps && chown -R user:user /var/lib/gitlab-deps && \
chmod +x /tmp/gitlab-deps/contrib/* && \
sed -i 's@usr/sbin@usr/local/sbin@' /tmp/gitlab-deps/contrib/* && \
sed -i 's@usr/bin@usr/local/bin@' /tmp/gitlab-deps/contrib/* && \
sed -i 's/^reload=.*/reload=0/' /tmp/gitlab-deps/contrib/update.sh && \
cp -a /tmp/gitlab-deps/contrib/start-server.sh /usr/local/sbin/gitlab-deps-server-wrapper && \
cp -a /tmp/gitlab-deps/contrib/update.sh /usr/local/sbin/update-gitlab-deps && \
rm -rf /var/cache/dnf /tmp/gitlab-deps
USER user:user
EXPOSE 3535
VOLUME /var/lib/gitlab-deps
CMD ["/usr/local/sbin/gitlab-deps-server-wrapper"]
# gitlab-deps Container
This is a container build for [Autistici's gitlab-deps orchestrator](https://git.autistici.org/ai3/tools/gitlab-deps)
The default entry point is the server wrapper.
## Running
mkdir data
echo MY_GITLAB_TOKEN > token
podman run --read-only -p 3535 -v $(pwd)/data:/var/lib/gitlab-deps:rw,Z -v $(pwd)/token:/secrets/gitlab-token:ro,Z -e PROJECT_REGEXP='^immerda/.*' -e GITLAB_URL=https://code.immerda.ch -e GITLAB_TOKEN_FILE=/secrets/gitlab-token --userns=keep-id -it
See upstream documentation for usage.
#!/bin/bash -e
NAME=gitlab-deps
VERSION=$(date '+%Y%m%d%H%M').$(git rev-parse --short HEAD)
git clone -q https://git.autistici.org/ai3/tools/gitlab-deps
cd gitlab-deps
VERSION="${VERSION}.$(git rev-parse --short HEAD)"
function finish {
rm -f ./cred.json ./*.tar
}
trap finish EXIT
if [ -z "${CI_REGISTRY_USER}" ] || [ -z "${CI_REGISTRY_PASSWORD}" ] || [ -z "${CI_REGISTRY_IMAGE}" ] || [ -z "${CI_REGISTRY}" ]; then
echo "Must specify CI_REGISTRY_USER, CI_REGISTRY_PASSWORD, CI_REGISTRY_IMAGE and CI_REGISTRY env variables"
exit 1
fi
basedir="$(readlink -f "$(dirname "$0")")"
cd "${basedir}"
if [ "${NO_BUILD_CACHE}" == "true" ]; then
cache_flag='--no-cache'
else
cache_flag=''
fi
echo "Building image"
buildah bud --pull-always $cache_flag -f "./Containerfile" -t "${NAME}:${VERSION}" "${basedir}"
echo -e "Building image \033[0;32mdone\033[0m"
echo "Exporting image"
podman save "${NAME}:${VERSION}" --output "${basedir}/${NAME}-${VERSION}.tar"
echo -e "Exporting image \033[0;32mdone\033[0m"
echo -e "{\"auths\":{\"${CI_REGISTRY}\": {\"auth\":\"$(echo -n "${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}" | base64)\"}}}" > ./cred.json
for ver in "${VERSION}" latest; do
echo "Pushing image as ref ${ver}"
skopeo copy --authfile ./cred.json "docker-archive:${basedir}/${NAME}-${VERSION}.tar" "docker://${CI_REGISTRY_IMAGE}:${ver}"
echo -e "Pushing image as ref ${ver} \033[0;32mdone\033[0m"
done
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment