From c91dfb87c92938c8d8f9296a999d120c9bcf1cd8 Mon Sep 17 00:00:00 2001 From: Georgios Jason Efstathiou Date: Fri, 17 Jan 2025 20:31:36 +0100 Subject: [PATCH] init --- Dockerfile | 26 ++++++++++++++++++++++++++ Jenkinsfile | 28 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Dockerfile create mode 100644 Jenkinsfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d14a4b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM jenkins/inbound-agent:alpine + +USER root + +# Alpine seems to come with libcurl baked in, which is prone to mismatching +# with newer versions of curl. The solution is to upgrade libcurl. +RUN apk add --no-cache -u libcurl curl +# Install Docker client +ARG DOCKER_VERSION=24.0.6 +ARG DOCKER_COMPOSE_VERSION=1.21.0 +ARG DOCKER_BUILDX_VERSION=0.16.0 +RUN curl -fsSL https://download.docker.com/linux/static/stable/`uname -m`/docker-$DOCKER_VERSION.tgz | tar --strip-components=1 -xz -C /usr/local/bin docker/docker +RUN curl -fsSL https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose + +# Enable buildx plugin +## buildx is released as amd64, and uname calls it x86_64 +RUN uname -m > /tmp/arch \ + && sed -i 's/x86_64/amd64/g' /tmp/arch \ + && mkdir -p /usr/libexec/docker/cli-plugins/ \ + && curl -fsSL https://github.com/docker/buildx/releases/download/v$DOCKER_BUILDX_VERSION/buildx-v$DOCKER_BUILDX_VERSION.linux-`cat /tmp/arch` > /usr/libexec/docker/cli-plugins/docker-buildx \ + && chmod +x /usr/libexec/docker/cli-plugins/docker-buildx \ + && docker buildx install \ + && rm /tmp/arch + +RUN touch /debug-flag +USER jenkins diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..2a54520 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,28 @@ +pipeline { + agent any + + environment { + REGISTRY = "docker-registry.service.consul" + IMAGE_NAME = "efstajas/jenkins-inbound-agent-with-docker" + } + + stages { + stage('Docker Build') { + steps { + script { + dockerImage = docker.build("$IMAGE_NAME") + } + } + } + + stage('Docker Publish') { + steps { + script { + docker.withRegistry("http://$REGISTRY:4124") { + dockerImage.push("latest") + } + } + } + } + } +}