diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..522f53a --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +REGISTRY?=swh-jenkins +DOCKERFILES=$(shell find * -type f -name Dockerfile) +NAMES=$(subst /,\:,$(subst /Dockerfile,,$(DOCKERFILES))) +IMAGES=$(addprefix $(REGISTRY)/,$(NAMES)) +DEPENDS=.depends.mk +MAKEFLAGS += -rR + +.PHONY: all run exec check checkrebuild $(NAMES) $(IMAGES) + +all: $(NAMES) + +help: + @echo "A smart Makefile for your dockerfiles" + @echo "" + @echo "Read all Dockerfile within the current directory and generate dependendies automatically." + @echo "" + @echo "make all ; build all images" + @echo "make checkrebuild all ; build and check if image has update availables (using apk or apt-get)" + @echo " and rebuild with --no-cache is image has updates" + @echo "" + @echo "You can chain actions, typically in CI environment you want make checkrebuild push all" + @echo "which rebuild and push only images having updates availables." + +.PHONY: $(DEPENDS) +$(DEPENDS): $(DOCKERFILES) + grep '^FROM \$$REGISTRY/' $(DOCKERFILES) | \ + awk -F '/Dockerfile:FROM \\$$REGISTRY/' '{ print $$1 " " $$2 }' | \ + sed 's@[:/]@\\:@g' | awk '{ print "$(REGISTRY)/" $$1 ": " "$(REGISTRY)/" $$2 }' > $@ +sinclude $(DEPENDS) + +$(NAMES): %: $(REGISTRY)/% +ifeq (run,$(filter run,$(MAKECMDGOALS))) + docker run --rm -it $< +endif +ifeq (exec,$(filter exec,$(MAKECMDGOALS))) + docker run --entrypoint sh --rm -it $< +endif +ifeq (check,$(filter check,$(MAKECMDGOALS))) + ./check_update.sh $< +endif + +$(IMAGES): %: + docker build -t $@ $(subst :,/,$(subst $(REGISTRY)/,,$@)) +ifeq (checkrebuild,$(filter checkrebuild,$(MAKECMDGOALS))) + ./check_update.sh $@ || (docker build --build-arg REGISTRY=$(REGISTRY) --no-cache -t $@ $(subst :,/,$(subst $(REGISTRY)/,,$@)) && ./check_update.sh $@) +endif diff --git a/README.md b/README.md new file mode 100644 index 0000000..7543804 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +swh-jenkins-dockerfiles +======================= + +This repo contains Dockerfile used to build the Jenkins' workers for the +Software Heritage continuous integration platform. + +Docker images should be built themselves by a Jenkins job. diff --git a/base/Dockerfile b/base/Dockerfile new file mode 100644 index 0000000..f8e513a --- /dev/null +++ b/base/Dockerfile @@ -0,0 +1,18 @@ +FROM jenkins/jnlp-slave +LABEL maintainer="SoftwareHeritage" +USER root + +# some base packages +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + build-essential \ + curl \ + python3-dev \ + python3-pip \ + python3-venv libsvn-dev \ + libsystemd-dev \ + pkg-config && \ + rm -rf /var/lib/apt/lists/* + +USER jenkins diff --git a/check_update.sh b/check_update.sh new file mode 100755 index 0000000..16338d9 --- /dev/null +++ b/check_update.sh @@ -0,0 +1,21 @@ +#!/bin/sh +if test -f /.dockerenv; then + if test -x /sbin/apk; then + apk --no-cache list -u | grep 'upgradable from' && exit 1 + elif test -x /usr/bin/apt-get; then + apt-get update > /dev/null + apt list --upgradable 2>/dev/null | grep 'upgradable from' && exit 1 + elif test -x /usr/bin/yum; then + yum check-update || exit 1 + fi + exit 0 +fi +if test -z "$1"; then + >&2 echo "$0 require image as argument" + exit 64 +fi +if docker run --rm --entrypoint sh -u root -v $(readlink -f $0):/check_update.sh $1 /check_update.sh; then + echo "\033[0;32m$1 is up-to-date\033[0m" +else + echo "\033[0;31m$1 need update\033[0m" && exit 1 +fi diff --git a/sphinx/Dockerfile b/sphinx/Dockerfile new file mode 100644 index 0000000..67cab60 --- /dev/null +++ b/sphinx/Dockerfile @@ -0,0 +1,18 @@ +ARG REGISTRY=swh-jenkins +FROM $REGISTRY/base + +USER root +RUN DEBIAN_FRONTEND=noninteractive apt-get update && \ + apt-get install -y --no-install-recommends \ + python3-sphinx \ + sphinx-rtd-theme-common \ + graphviz \ + python3-sphinxcontrib.httpdomain \ + python3-recommonmark \ + libffi-dev \ + inkscape \ + myrepos \ + make && \ + rm -rf /var/lib/apt/lists/* + +USER jenkins diff --git a/tox/Dockerfile b/tox/Dockerfile new file mode 100644 index 0000000..6f4ca30 --- /dev/null +++ b/tox/Dockerfile @@ -0,0 +1,22 @@ +ARG REGISTRY=swh-jenkins +FROM $REGISTRY/base +LABEL maintainer="SoftwareHeritage" +USER root + +# install postgresql 10 +RUN echo deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main > /etc/apt/sources.list.d/postgres.list +RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +RUN apt-get update && \ + apt-get install -y \ + postgresql-10 \ + postgresql-client-10 \ + libpq-dev \ + arcanist && \ + rm -rf /var/lib/apt/lists/* + +USER jenkins + +RUN python3 -m pip install --user --upgrade \ + pip setuptools tox wheel +RUN python3 -m pip install --user --no-warn-script-location \ + Radon pylint coverage codespell