From a599451c4f0205da6762e10adf591e613401143c Mon Sep 17 00:00:00 2001 From: surtur Date: Wed, 19 Jan 2022 17:29:03 +0100 Subject: [PATCH] initial commit --- .hadolint.yaml | 19 +++++++++++ .pre-commit-config.yaml | 7 ++++ Dockerfile | 74 +++++++++++++++++++++++++++++++++++++++++ Makefile | 34 +++++++++++++++++++ README.md | 7 ++++ hooks/build | 11 ++++++ 6 files changed, 152 insertions(+) create mode 100644 .hadolint.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 hooks/build diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..fb42171 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,19 @@ +failure-threshold: warning + +ignored: + # updated nightly so this is irrelevant + - DL3039 + # DL3041 warning: Specify version with `dnf install -y -`. + - DL3041 + # DL3040 warning: `dnf clean all` missing after dnf command. + - DL3040 + # SC2039 warning: In POSIX sh, brace expansion is undefined. + # it actually still works + - SC2039 + +no-fail: true + +override: + info: + # SC3009 warning: In POSIX sh, brace expansion is undefined. + - SC3009 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..69f6a54 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +--- +fail_fast: false +repos: + - repo: https://github.com/hadolint/hadolint + rev: v2.8.0 + hooks: + - id: hadolint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d3493c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,74 @@ +# syntax=docker/dockerfile:1.3 +FROM registry.fedoraproject.org/fedora:35 + +ARG BUILD_DATE +ARG VCS_REF + +LABEL description="Container image for distributed building of C/C++ programs on Fedora using distcc" + +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.vcs-url="https://git.dotya.ml/wanderer/docker-fedora-distcc.git" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.license=GPL-3.0 + +# hadolint shell=/usr/bin/bash +RUN printf "[main]\ngpg_check=1\ninstallonly_limit=2\nclean_requirements_on_remove=True\nfastestmirror=True\nmax_parallel_downloads=7\n" > /etc/dnf/dnf.conf; \ + cat /etc/dnf/dnf.conf; \ + dnf install 'dnf-command(config-manager)' -y && \ + dnf config-manager --set-enabled updates && \ + dnf config-manager --set-enabled updates-testing && \ + dnf --refresh upgrade -y +# hadolint ignore DL3059 +RUN dnf install --nodocs dnf dnf-plugins-core -y && \ + dnf copr enable eddsalkield/iwyu -y && \ + dnf install --nodocs --setopt install_weak_deps=0 -y \ + git \ + ninja-build \ + make \ + {c,auto}make \ + gcc \ + gcc-c++ \ + libgcc \ + libstdc++-{devel,static} \ + glibc-devel \ + clang \ + distcc \ + distcc-server \ + iwyu \ + cryptopp-devel \ + libasan-static \ + liblsan-static \ + libubsan-static \ + libtsan-static \ + binutils \ + lld \ + flex \ + bison \ + which \ + file \ + protobuf-c-{devel,compiler} \ + protobuf-compiler \ + cppunit \ + capnproto-{devel,libs} \ + libpcap-devel \ + kernel-devel \ + && dnf clean all -y + +ENTRYPOINT ["distccd", \ + "--daemon", \ + "--no-detach", \ + "--user", "distcc", \ + "--port", "3632", \ + "--stats", \ + "--stats-port", "3633", \ + "--log-stderr", \ + "--listen", "0.0.0.0"\ +] + +# By default the distcc server will accept clients from everywhere. +CMD ["--allow", "0.0.0.0/0", \ + "--nice", "3", \ + "--jobs", "6" \ +] + + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4886e00 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +dcmd = docker +dfile = Dockerfile +dtag = immawanderer/fedora-distcc:testbuild +dargs = build -t $(dtag) --no-cache --pull - < $(dfile) +cleanargs = image rm -f $(dtag) +pruneargs = system prune -af +dargskaniko = run --rm -it -w=$(kanikowdir) -v $$PWD:$(kanikowdir) +kanikoexecutorimg = gcr.io/kaniko-project/executor:v1.7.0-debug +kanikowdir = /src +kanikocontext = . +kanikoargs = -f=$(dfile) -c=$(kanikocontext) --use-new-run --snapshotMode=redo --build-arg BUILD_DATE=$(build_date) --build-arg VCS_REF=$(vcs_ref) --no-push +vcs_ref = $$(git rev-parse --short HEAD) +build_date= $$(date -u +"%Y-%m-%dT%H:%M:%SZ") +hadolintimg = hadolint/hadolint:v2.8.0-alpine +hadolintargs = run --rm -i -v $$PWD/.hadolint.yaml:/root/.config/hadolint.yaml + +.PHONY: hadolint build kaniko clean test prune + +hadolint: + $(dcmd) $(hadolintargs) $(hadolintimg) < $(dfile) + +kaniko: + $(dcmd) $(dargskaniko) $(kanikoexecutorimg) $(kanikoargs) + +build: + $(dcmd) $(dargs) + +clean: + $(dcmd) $(cleanargs) + +test: hadolint build kaniko + +prune: + $(dcmd) $(pruneargs) diff --git a/README.md b/README.md new file mode 100644 index 0000000..7ae6985 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# docker-fedora-distcc + +This repository provides a Dockerfile to create a container image for distributed building of C/C++ programs on Fedora using distcc. + +The image is rebuilt nightly to ensure it always has the latest packages. + +development happens on [this Gitea instance](https://git.dotya.ml/wanderer/docker-fedora-distcc) diff --git a/hooks/build b/hooks/build new file mode 100644 index 0000000..7a366b4 --- /dev/null +++ b/hooks/build @@ -0,0 +1,11 @@ +#!/bin/bash + +# as per https://github.com/rossf7/label-schema-automated-build + +# $IMAGE_NAME var is injected into the build so the tag is correct. + +export DOCKER_BUILDKIT=1 +echo "Build hook running" +docker build --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ + --build-arg VCS_REF=`git rev-parse --short HEAD` \ + -t $IMAGE_NAME .