Implement builder image

Add docker build to create a shared image for running CI pipelines and
docker builds based on debian.
This commit is contained in:
Hornwitser 2024-07-13 12:26:16 +02:00
commit c3e3ff0959
4 changed files with 64 additions and 0 deletions

17
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,17 @@
default:
image: docker:24.0.5
build:
stage: build
script:
- docker build $CI_PROJECT_DIR
--tag ${REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
$(echo "$CI_COMMIT_TAG" | if grep -q $(date -u '+^r%g\.%-V\.\(0\|[1-9][0-9]*\)$');
then echo --tag ${REGISTRY_IMAGE}:latest;
fi)
deploy:
stage: deploy
script:
- echo "$REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $REGISTRY_USER --password-stdin
- docker push --all-tags ${REGISTRY_IMAGE}

27
Dockerfile Normal file
View file

@ -0,0 +1,27 @@
FROM debian:bookworm
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
; \
install -m 0755 -d /etc/apt/keyrings; \
curl -sSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc; \
chmod a+r /etc/apt/keyrings/docker.asc; \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/debian \
bookworm stable" \
> /etc/apt/sources.list.d/docker.list; \
apt-get update; \
apt-get install -y --no-install-recommends \
docker-ce-cli \
docker-buildx-plugin \
docker-compose-plugin \
; \
rm -rf /var/lib/apt/lists/*
# References:
# - docker: https://docs.docker.com/engine/install/debian/#install-from-a-package

9
Readme.md Normal file
View file

@ -0,0 +1,9 @@
# Builder
Common docker image used for running application builds, CI pipelines, and deployment scripts based on Debian 12.
## Tools included
- `docker`
- `curl`
- `git`

11
tag-release.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/bash
# Finds the next available r<year>.<week>.<bump> identifier for the current year and week
YEAR_WEEK=$(date -u +%g.%-V)
YEAR=${YEAR_WEEK:0:2}
WEEK=${YEAR_WEEK:3}
LAST_BUMP=$(git tag --list | grep '^r'$YEAR'\.'$WEEK'\.\(0\|[1-9][0-9]*\)$' | cut -d . -f 3 | sort -nr | head -n 1)
RELEASE=r${YEAR_WEEK}.$(( ${LAST_BUMP:--1} + 1 ))
git tag $RELEASE
echo Tagged $RELEASE