Browse Source

ci: create initial gitlab-ci jobs

Adds two simple jobs for building the library for Debian 10 and CentOS 8

They will pull down docker images containing the dependencies needed for
libpEpAdapter, then proceed with the build. Upon successful compilation,
an image containing the ouput (and dependencies) will be pushed to a
docker registry on the CI infrastructure.

Note about the docker images in use:
Currently they pull the latest docker images containing pEpEngine,
Sequoia, and other dependencies. We want to specify the exact required
version in future updates to the jobs.
android-build
Devan Carpenter 9 months ago
parent
commit
e9ff229630
8 changed files with 151 additions and 0 deletions
  1. +34
    -0
      .gitlab-ci-files/common-prepare.yml
  2. +25
    -0
      .gitlab-ci.yml
  3. +15
    -0
      scripts/centos8/Makefile
  4. +8
    -0
      scripts/centos8/build_libpEpAdapter.sh
  5. +23
    -0
      scripts/centos8/libpEpAdapter.centos8.Dockerfile
  6. +15
    -0
      scripts/debian10/Makefile
  7. +8
    -0
      scripts/debian10/build_libpEpAdapter.sh
  8. +23
    -0
      scripts/debian10/libpEpAdapter.debian10.Dockerfile

+ 34
- 0
.gitlab-ci-files/common-prepare.yml View File

@ -0,0 +1,34 @@
.ensure_docker: &ensure_docker
# Check for docker and install if missing
- 'which docker || ( sudo apt-get update -y && sudo apt-get install docker.io -y )'
.ensure_rsync: &ensure_rsync
# Install rsync and deps if missing
- 'which ssh-agent || ( sudo apt-get update -y && sudo apt-get install openssh-client -y )'
- 'which rsync || ( sudo apt-get update -y && sudo apt-get install rsync -y )'
- 'which make || ( sudo apt-get update -y && sudo apt-get install make -y )'
.enable_insecure_docker_registries: &enable_insecure_docker_registries
# Enable "insecure" docker registries
- |
cat <<EOD > /tmp/docker-daemon.json
{
"insecure-registries" : ["${DOCKER_REGISTRY_HOST}"]
}
EOD
- sudo cp /tmp/docker-daemon.json /etc/docker/daemon.json
- sudo systemctl restart docker.service
.standard_job:
tags: [kvm]
before_script:
- *ensure_docker
- *ensure_rsync
- *enable_insecure_docker_registries
.make_in_docker:
extends: .standard_job
script:
- docker login -u ${DOCKER_REGISTRY_USER} -p ${DOCKER_REGISTRY_PASS} ${DOCKER_REGISTRY_HOST}
- cd scripts/${CI_DISTRO_TARGET}
- make

+ 25
- 0
.gitlab-ci.yml View File

@ -0,0 +1,25 @@
include:
- '.gitlab-ci-files/common-prepare.yml'
stages:
- build
# CentOS/RHEL
centos8:build:
extends: .make_in_docker
stage: build
variables:
CI_MAKE_TARGET: libpepadapter
CI_DISTRO_TARGET: centos8
# Debian
debian10:build:
extends: .make_in_docker
stage: build
variables:
CI_MAKE_TARGET: libpepadapter
CI_DISTRO_TARGET: debian10
DEBIAN_FRONTEND: noninteractive

+ 15
- 0
scripts/centos8/Makefile View File

@ -0,0 +1,15 @@
CURRENT_DISTRO=$(shell basename $(shell pwd))
LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD)
IMAGE_NAME=${DOCKER_REGISTRY_HOST}/pep-$(CURRENT_DISTRO)-libpepadapter
DOCKERFILE=libpEpAdapter.$(CURRENT_DISTRO).Dockerfile
all:
-docker pull $(IMAGE_NAME):latest
cd ../../ && docker build --build-arg CURRENT_DISTRO=$(CURRENT_DISTRO) \
--build-arg DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST} \
--build-arg LIBPEPADAPTER_VERSION=$(LIBPEPADAPTER_VERSION) \
--cache-from $(IMAGE_NAME):latest \
--tag=$(IMAGE_NAME):$(LIBPEPADAPTER_VERSION) \
--tag=$(IMAGE_NAME):latest \
-f scripts/${CURRENT_DISTRO}/$(DOCKERFILE) .
docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION}
docker push $(IMAGE_NAME):latest

+ 8
- 0
scripts/centos8/build_libpEpAdapter.sh View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -exo
echo "ENGINE_LIB_PATH=${INSTPREFIX}/lib" >> local.conf
echo "ENGINE_INC_PATH=${INSTPREFIX}/include" >> local.conf
make
make install PREFIX="${INSTPREFIX}"

+ 23
- 0
scripts/centos8/libpEpAdapter.centos8.Dockerfile View File

@ -0,0 +1,23 @@
ARG DOCKER_REGISTRY_HOST
ARG CURRENT_DISTRO
ARG PEPENGINE_VERSION=latest
FROM ${DOCKER_REGISTRY_HOST}/pep-${CURRENT_DISTRO}-engine:${PEPENGINE_VERSION}
ENV BUILDROOT /build
ENV INSTPREFIX /install
ENV OUTDIR /out
### Setup working directory
RUN mkdir ${BUILDROOT}/libpEpAdapter
COPY . ${BUILDROOT}/libpEpAdapter
USER root
RUN chown -R pep-builder:pep-builder ${BUILDROOT}/libpEpAdapter
USER pep-builder
WORKDIR ${BUILDROOT}/libpEpAdapter
ARG LIBPEPADAPTER_VERSION
ARG CURRENT_DISTRO
### Build libpEpAdapter
RUN sh ./scripts/${CURRENT_DISTRO}/build_libpEpAdapter.sh && \
rm -rf ${BUILDROOT}/*

+ 15
- 0
scripts/debian10/Makefile View File

@ -0,0 +1,15 @@
CURRENT_DISTRO=$(shell basename $(shell pwd))
LIBPEPADAPTER_VERSION=$(shell git rev-parse --short=8 HEAD)
IMAGE_NAME=${DOCKER_REGISTRY_HOST}/pep-$(CURRENT_DISTRO)-libpepadapter
DOCKERFILE=libpEpAdapter.$(CURRENT_DISTRO).Dockerfile
all:
-docker pull $(IMAGE_NAME):latest
cd ../../ && docker build --build-arg CURRENT_DISTRO=$(CURRENT_DISTRO) \
--build-arg DOCKER_REGISTRY_HOST=${DOCKER_REGISTRY_HOST} \
--build-arg LIBPEPADAPTER_VERSION=$(LIBPEPADAPTER_VERSION) \
--cache-from $(IMAGE_NAME):latest \
--tag=$(IMAGE_NAME):$(LIBPEPADAPTER_VERSION) \
--tag=$(IMAGE_NAME):latest \
-f scripts/${CURRENT_DISTRO}/$(DOCKERFILE) .
docker push $(IMAGE_NAME):${LIBPEPADAPTER_VERSION}
docker push $(IMAGE_NAME):latest

+ 8
- 0
scripts/debian10/build_libpEpAdapter.sh View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -exo
echo "ENGINE_LIB_PATH=${INSTPREFIX}/lib" >> local.conf
echo "ENGINE_INC_PATH=${INSTPREFIX}/include" >> local.conf
make
make install PREFIX="${INSTPREFIX}"

+ 23
- 0
scripts/debian10/libpEpAdapter.debian10.Dockerfile View File

@ -0,0 +1,23 @@
ARG DOCKER_REGISTRY_HOST
ARG CURRENT_DISTRO
ARG PEPENGINE_VERSION=latest
FROM ${DOCKER_REGISTRY_HOST}/pep-${CURRENT_DISTRO}-engine:${PEPENGINE_VERSION}
ENV BUILDROOT /build
ENV INSTPREFIX /install
ENV OUTDIR /out
### Setup working directory
RUN mkdir ${BUILDROOT}/libpEpAdapter
COPY . ${BUILDROOT}/libpEpAdapter
USER root
RUN chown -R pep-builder:pep-builder ${BUILDROOT}/libpEpAdapter
USER pep-builder
WORKDIR ${BUILDROOT}/libpEpAdapter
ARG LIBPEPADAPTER_VERSION
ARG CURRENT_DISTRO
### Build libpEpAdapter
RUN sh ./scripts/${CURRENT_DISTRO}/build_libpEpAdapter.sh && \
rm -rf ${BUILDROOT}/*

Loading…
Cancel
Save