Skip to content
Snippets Groups Projects
Commit 596f0425 authored by Jiří Ježek's avatar Jiří Ježek Committed by František Řezníček
Browse files

Fix build-master job, added script for install packages (apk)

parent 0e50f628
No related branches found
No related tags found
1 merge request!7Fix build-master job, added script for install packages (apk)
...@@ -5,24 +5,31 @@ stages: ...@@ -5,24 +5,31 @@ stages:
# common parts -------------------------------------------------------------- # common parts --------------------------------------------------------------
image: registry.gitlab.ics.muni.cz:443/cloud/container-registry/docker:latest image: registry.gitlab.ics.muni.cz:443/cloud/container-registry/docker:latest
services:
- name: registry.gitlab.ics.muni.cz:443/cloud/container-registry/docker:latest-dind
alias: docker
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
.common-artifacts: &common-artifacts
artifacts:
expire_in: 14 days
when: always
name: logs
paths:
- "*.log"
# build jobs ---------------------------------------------------------------- # build jobs ----------------------------------------------------------------
.build-common: &build-common .build-common: &build-common
<<: *common-artifacts
stage: build stage: build
before_script:
- ci/dependencies/install-pkgs-apk.sh ci/dependencies/requirements-build-common.apk > pkgs-install.log
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script: | script: |
export DOCKER_CONTENT_TRUST=1
for i_image_tag in ${IMAGES}; do for i_image_tag in ${IMAGES}; do
export DOCKER_CONTENT_TRUST=1
i_image_dir=$(echo "${i_image_tag}" | awk 'BEGIN{FS=":"}{printf $NF}') i_image_dir=$(echo "${i_image_tag}" | awk 'BEGIN{FS=":"}{printf $NF}')
docker build --pull -t "${CONTAINER_IMAGE_REGISTRY_NAMESPACE}/${i_image_tag}" ./${i_image_dir} podman build --pull -t "${CONTAINER_IMAGE_REGISTRY_NAMESPACE}/${i_image_tag}" ./${i_image_dir}
export DOCKER_CONTENT_TRUST=0 podman push "${CONTAINER_IMAGE_REGISTRY_NAMESPACE}/${i_image_tag}"
docker push "${CONTAINER_IMAGE_REGISTRY_NAMESPACE}/${i_image_tag}"
done done
build-master: build-master:
...@@ -46,8 +53,9 @@ build-branches: ...@@ -46,8 +53,9 @@ build-branches:
- tags - tags
build-pull-tag-push: build-pull-tag-push:
<<: *common-artifacts
# avoiding pip's externally-managed-environment error https://gitlab.ics.muni.cz/cloud/container-registry/-/jobs/904509 # avoiding pip's externally-managed-environment error https://gitlab.ics.muni.cz/cloud/container-registry/-/jobs/904509
image: debian:11 image: debian:12
stage: build stage: build
variables: variables:
IMAGES: "centos:7 centos:8 almalinux:8 rockylinux:8 debian:10 debian:10-slim debian:11 debian:11-slim" IMAGES: "centos:7 centos:8 almalinux:8 rockylinux:8 debian:10 debian:10-slim debian:11 debian:11-slim"
...@@ -57,11 +65,10 @@ build-pull-tag-push: ...@@ -57,11 +65,10 @@ build-pull-tag-push:
SSHUTTLE_ROUTED_SUBNETS: "10.16.0.0/16 147.251.62.0/24 147.251.63.0/24" SSHUTTLE_ROUTED_SUBNETS: "10.16.0.0/16 147.251.62.0/24 147.251.63.0/24"
SSHUTTLE_EXCLUDED_SUBNETS: "147.251.62.9/32" SSHUTTLE_EXCLUDED_SUBNETS: "147.251.62.9/32"
before_script: before_script:
- ci/dependencies/install-pkgs.sh ci/dependencies/requirements.apt > pkgs-install.log - ci/dependencies/install-pkgs-apt.sh ci/dependencies/requirements.apt > pkgs-install.log
- ci/dependencies/install-pymodules.sh ci/dependencies/requirements.pip > pymodules-install.log - ci/dependencies/install-pymodules.sh ci/dependencies/requirements.pip > pymodules-install.log
- service docker start - service docker start
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- mkdir -p "${HOME}/.ssh" - mkdir -p "${HOME}/.ssh"
- ssh_private_key_file="SSH_PRIVATE_KEY_PRODUCTION" - ssh_private_key_file="SSH_PRIVATE_KEY_PRODUCTION"
- cp -f "${!ssh_private_key_file}" "${HOME}/.ssh/id_rsa" - cp -f "${!ssh_private_key_file}" "${HOME}/.ssh/id_rsa"
...@@ -80,8 +87,7 @@ build-pull-tag-push: ...@@ -80,8 +87,7 @@ build-pull-tag-push:
.upstream-container-release-downstream: &upstream-container-release-downstream .upstream-container-release-downstream: &upstream-container-release-downstream
stage: upstream-container-release-downstream stage: upstream-container-release-downstream
script: | script: |
apk update ci/dependencies/install-pkgs-apk.sh ci/dependencies/requirements-build-pull-tag-push.apk > pkgs-install.log
apk add gettext gawk
export BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S) export BUILD_DATE=$(date +%Y-%m-%dT%H:%M:%S)
export CI_BUILD_HOSTNAME="$(hostname)" export CI_BUILD_HOSTNAME="$(hostname)"
export CONTAINER_IMAGE_TAG="$(echo "${CI_COMMIT_TAG}" | awk -F/ '{printf $2}')" export CONTAINER_IMAGE_TAG="$(echo "${CI_COMMIT_TAG}" | awk -F/ '{printf $2}')"
...@@ -100,13 +106,13 @@ build-pull-tag-push: ...@@ -100,13 +106,13 @@ build-pull-tag-push:
echo "Releasing ${DEST_IMAGE_NAME} also as ${i_dest_image_name}" echo "Releasing ${DEST_IMAGE_NAME} also as ${i_dest_image_name}"
docker push "${i_dest_image_name}" docker push "${i_dest_image_name}"
done done
artifacts: artifacts:
expire_in: 1 mo expire_in: 1 mo
when: always when: always
name: upstream-app-dockerfiles name: upstream-app-dockerfiles
paths: paths:
- upstream-app/Dockerfile* - upstream-app/Dockerfile*
- "*.log"
node-exporter: node-exporter:
<<: *upstream-container-release-downstream <<: *upstream-container-release-downstream
......
#!/bin/sh
#
# install-pkgs-apk.sh <pkg-requirement-file> ... [pkg-repository-url] ... [package-name] ...
#
# installs linux packages from various sources
# * <pkg-requirement-file> i.e. packages listed in text file
# * [pkg-repository-url] i.e. enable foreign package repository
# * [package-name] i.e. explicitly listed packages
#
# Note: Only Alpine-like Linux distros with apk are supported at the moment
set -eo pipefail
APT='apk'
function install_pkgs_from_requirement_file() {
local file="$1"
${APT} add $(grep -v '^#' "${file}")
}
function install_pkg_repository() {
local repo_url="$1"
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> "/etc/apk/repositories"
yum-config-manager --add-repo "${repo_url}"
}
function install_pkgs() {
${APT} add "$@"
}
apk update
for i_arg in "$@"; do
if [ -r "${i_arg}" ]; then
install_pkgs_from_requirement_file "${i_arg}"
elif [[ "${i_arg}" =~ https?://.+ ]]; then
install_pkg_repository "${i_arg}"
else
install_pkgs "${i_arg}"
fi
done
#!/usr/bin/env bash #!/usr/bin/env bash
# #
# install-pkgs.sh <pkg-requirement-file> ... [pkg-repository-url] ... [package-name] ... # install-pkgs-apt.sh <pkg-requirement-file> ... [pkg-repository-url] ... [package-name] ...
# #
# installs linux packages from various sources # installs linux packages from various sources
# * <pkg-requirement-file> i.e. packages listed in text file # * <pkg-requirement-file> i.e. packages listed in text file
# * [pkg-repository-url] i.e. enable foreign package repository # * [pkg-repository-url] i.e. enable foreign package repository
# * [package-name] i.e. explicitly listed packages # * [package-name] i.e. explicitly listed packages
# #
# Note: Only RHEL-like Linux distros with yum are supported at the moment # Note: Only Debian/Ubuntu-like Linux distros with apt are supported at the moment
set -eo pipefail set -eo pipefail
......
podman
\ No newline at end of file
gettext
gawk
\ No newline at end of file
python3-pip python3-pip
docker.io docker.io
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment