initial commit
Gitea/docker-base-images/alpine-base/pipeline/head There was a failure building this commit Details

master release-1.0.0-3.17.3
amorozov 2023-04-04 20:15:33 +03:00
commit 0001b32707
2 changed files with 67 additions and 0 deletions

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
ARG BASE_IMAGE="alpine:3.17.3"
FROM ${BASE_IMAGE}
RUN apk update && \
apk add --no-cache openssh git curl
RUN curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \
&& tar xzvf docker-17.04.0-ce.tgz \
&& mv docker/docker /usr/local/bin \
&& rm -r docker docker-17.04.0-ce.tgz

55
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,55 @@
def resolveImageTag(env) {
return env.TAG_NAME?.replace(env.RELEASE_TAG_PREFIX, '') ?: 'latest'
}
def resolveImageName(env) {
return "${env.REGISTRY_HOST}/docker-base-images/${env.IMAGE_BASE_NAME}:${resolveImageTag(env)}"
}
pipeline {
agent {
docker {
image 'alpine:3.17.3'
// Mount docker socket for docker-in-docker
args '-v /var/run/docker.sock:/var/run/docker.sock'
}
}
stages {
stage('prepare') {
steps {
sh """
apk update && \
apk add --no-cache git curl
"""
sh """curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.04.0-ce.tgz \
&& tar xzvf docker-17.04.0-ce.tgz \
&& mv docker/docker /usr/local/bin \
&& rm -r docker docker-17.04.0-ce.tgz"""
script {
env.IMAGE_BASE_NAME = "alpine-base"
env.RELEASE_TAG_PREFIX = "release-"
env.REGISTRY_HOST = "git.tswf.io"
if (env.TAG_NAME == null) {
env.TAG_NAME = sh(returnStdout: true, script: "git tag --points-at HEAD").trim()
}
}
}
}
stage('build_docker') {
steps {
sh "docker build . --tag ${resolveImageName(env)}"
}
}
stage('push_docker') {
when {
tag "${env.RELEASE_TAG_PREFIX}*"
}
steps {
sh "docker login ${env.REGISTRY_HOST} -u ${env.GITEA_USER} -p ${env.GITEA_OAUTH_TOKEN}"
sh "docker image push ${resolveImageName(env)}"
}
}
}
}