commit 9cb30c411251d030e7ddbd61a9c472896b80fd6b Author: surtur Date: Wed May 5 21:51:42 2021 +0200 initial commit diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fd1a4b1 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,137 @@ +--- +kind: pipeline +type: docker +name: testing + +platform: + os: linux + arch: amd64 + +steps: +- name: kaniko-build + pull: always + image: immawanderer/drone-kaniko:linux-amd64 + settings: + dockerfile: Dockerfile + context: . + when: + ref: + - "refs/heads/feature-**" + - "refs/pull/**" + - "refs/tags/**" + event: + exclude: [cron] + +- name: kaniko-publish + pull: always + image: immawanderer/drone-kaniko:linux-amd64 + settings: + dockerfile: Dockerfile + context: . + tags: + - latest + - linux-amd64 + - ${DRONE_COMMIT_SHA:0:8} + repo: immawanderer/fedora-cpp + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + ref: + - refs/heads/dev + event: + exclude: [pull_request, tag] + +trigger: + event: [push, pull_request, cron, tag] + +--- +kind: pipeline +type: docker +name: notifications + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +steps: +- name: discord + pull: if-not-exists + image: appleboy/drone-discord:latest + settings: + message: > + {{#success build.status}} + ✅ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` succeeded. + event: **`{{build.event}}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{else}} + ❌ [Build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed. + event: **`${DRONE_BUILD_EVENT}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + ```{{commit.message}}``` + {{/success}} + webhook_id: + from_secret: discord_webhook_id + webhook_token: + from_secret: discord_webhook_token + +trigger: + event: + exclude: [pull_request] + include: [push, tag] + status: + - success + - failure + +depends_on: +- testing + +--- +kind: pipeline +type: docker +name: notifications-cronbuild + +platform: + os: linux + arch: amd64 + +clone: + disable: true + +steps: +- name: discord + pull: always + image: appleboy/drone-discord:latest + settings: + message: > + {{#success build.status}} + ✅ [Nightly build #{{build.number}}]({{build.link}}) of `{{repo.name}}` succeeded. + event: **`{{build.event}}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{else}} + ❌ [Nightly build #{{build.number}}]({{build.link}}) of `{{repo.name}}` failed. + event: **`${DRONE_BUILD_EVENT}`** + commit [`${DRONE_COMMIT_SHA:0:7}`](https://git.dotya.ml/${DRONE_REPO}/commit/${DRONE_COMMIT_SHA}) by {{commit.author}} on `{{commit.branch}}` + {{/success}} + webhook_id: + from_secret: discord_webhook_hourly_id + webhook_token: + from_secret: discord_webhook_hourly_token + +trigger: + branch: + - dev + event: + - cron + cron: + - nightly + status: + - success + - failure + +depends_on: +- testing diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f8d76e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,63 @@ +# syntax=docker/dockerfile:1.2 +FROM registry.fedoraproject.org/fedora:34 + +ARG BUILD_DATE +ARG VCS_REF + +LABEL description="Container image mainly used for CI testing of C/C++ programs on Fedora" + +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.vcs-url="https://git.dotya.ml/wanderer/docker-fedora-cpp.git" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.license=GPL-3.0 + +RUN dnf --refresh upgrade -y \ + && dnf install -y \ + git \ + make \ + {c,auto}make \ + gcc \ + gcc-c++ \ + libgcc \ + libstdc++-{devel,static} \ + glibc-devel \ + binutils \ + flex \ + bison \ + openmpi-devel \ + which \ + file \ + grpc-{cli,cpp,devel,plugins} \ + protobuf-c-{devel,compiler} \ + protobuf-compiler \ + cppunit \ + log4cpp-devel \ + json-c-devel \ + capnproto-{devel,libs} \ + libpcap-devel \ + hiredis-devel \ + mongo-c-driver-{devel,libs} \ + boost-{devel,atomic,chrono,date-time,system,program-options,regex,thread} \ + libtool \ + autoconf \ + pkgconf \ + kernel-devel \ + ncurses-{c++-libs,devel,libs,static} \ + && dnf clean all -y + +# see https://git.dotya.ml/wanderer/docker-fedora-cpp/issues/1 +# +# building nDPI would fail with plain RUN and kaniko. +# having it wrapped in 'bash -c' helped +RUN bash -c 'export MAKEFLAGS="$MAKEFLAGS -j$(nproc)" && printf "$MAKEFLAGS\n"; \ + export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:$PATH"; \ + git clone https://github.com/ntop/nDPI.git /tmp/nDPI && \ + cd /tmp/nDPI ; \ + git checkout 1.7 && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make install' +RUN if [ -f /tmp/nDPI/config.log ]; then cat /tmp/nDPI/config.log; fi; \ + rm -rf /tmp/nDPI + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c737cfe --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +dcmd = docker +dfile = Dockerfile +dtag = immawanderer/fedora-cpp: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:debug +kanikowdir = /src +kanikocontext = . +kanikoargs = -f=$(dfile) -c=$(kanikocontext) --use-new-run --snapshotMode=redo --no-push --force + +.PHONY: build kaniko clean test prune + +kaniko: + $(dcmd) $(dargskaniko) $(kanikoexecutorimg) $(kanikoargs) + +build: + $(dcmd) $(dargs) + +clean: + $(dcmd) $(cleanargs) + +test: build kaniko + +prune: + $(dcmd) $(pruneargs) diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5cb23c --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# docker-fedora-cpp + +[![Build Status](https://drone.dotya.ml/api/badges/wanderer/docker-fedora-cpp/status.svg?ref=refs/heads/dev)](https://drone.dotya.ml/wanderer/docker-fedora-cpp) +[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/immawanderer/fedora-cpp)](https://hub.docker.com/r/immawanderer/fedora-cpp/tags/?page=1&ordering=last_updated) +[![Docker Image Version (tag latest semver)](https://img.shields.io/docker/v/immawanderer/archlinux/linux-amd64)](https://hub.docker.com/r/immawanderer/fedora-cpp/tags/?page=1&ordering=last_updated&name=linux-amd64) +[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/immawanderer/archlinux/linux-amd64)](https://hub.docker.com/r/immawanderer/fedora-cpp/tags/?page=1&ordering=last_updated&name=linux-amd64) +[![MicroBadger Layers (tag)](https://img.shields.io/microbadger/layers/immawanderer/archlinux/linux-amd64)](https://hub.docker.com/r/immawanderer/fedora-cpp/tags/?page=1&ordering=last_updated&name=linux-amd64) +[![Docker pulls](https://img.shields.io/docker/pulls/immawanderer/archlinux)](https://hub.docker.com/r/immawanderer/fedora-cpp/) + +This repository provides a Dockerfile to create a container image mainly used for CI testing of C/C++ programs on Fedora. + +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-cpp) + +## What you get +* updated `registry.fedoraproject.org/fedora:34` image +* the result of +```sh +dnf install -y make {c,auto}make autoconf lld binutils gcc gcc-c++ libgcc libstdc++-{devel,static} glibc-devel openmpi-devel bison flex grpc-{cli,cpp,devel,plugins} protobuf-c-{devel,compiler} protobuf-compiler cppunit log4cpp-devel json-c-devel capnproto-{devel,libs} libpcap-devel hiredis-devel mongo-c-driver-{devel,libs} boost-{devel,atomic,chrono,date-time,system,program-options,regex,thread} libtool libtool-ltdl which pkgconf openssl-devel kernel-devel ncurses-{c++-libs,devel,libs,static} && dnf clean all -y +``` +* compiled `github.com/ntop/nDPI.git` + +## Purpose +* testing c/cpp programs in CI without the need to install all of the deps (such as protobuf, capnproto, pcap, boost, etc...) all the time + found out that if there's enough deps it actually takes more time to pre-configure the environment than if a single image is downloaded once and reused (this one in drone CI) for all subsequent builds 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 .