ci: add Jenkinsfile, improve Dockerfile

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2024-05-20 18:42:30 +02:00
parent 3f49bcb6e9
commit b40732b442
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
3 changed files with 59 additions and 1 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
Jenkinsfile
README.md
build

View File

@ -14,8 +14,9 @@ FROM debian:12.5-slim
LABEL maintainer="richard@status.im" LABEL maintainer="richard@status.im"
LABEL source="https://github.com/waku-org/storenode-messages" LABEL source="https://github.com/waku-org/storenode-messages"
LABEL description="Storenode message count verifier" LABEL description="Storenode message count verifier"
LABEL commit="unknown"
COPY --from=builder /go/src/github.com/waku-org/storenode-messages/build/storemsgcounter /usr/local/bin/storemsgcounter COPY --from=builder /go/src/github.com/waku-org/storenode-messages/build/storemsgcounter /usr/local/bin/storemsgcounter
ENTRYPOINT ["/usr/local/bin/storemsgcounter"] ENTRYPOINT ["/usr/local/bin/storemsgcounter"]
CMD ["-help"] CMD ["-help"]

54
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,54 @@
#!/usr/bin/env groovy
pipeline {
agent { label 'linux' }
parameters {
string(
name: 'IMAGE_TAG',
defaultValue: params.IMAGE_TAG ?: 'latest',
description: 'Optional Docker image tag to push.'
)
}
options {
disableConcurrentBuilds()
/* manage how many builds we keep */
buildDiscarder(logRotator(
numToKeepStr: '20',
daysToKeepStr: '30',
))
}
environment {
DOCKER_REGISTRY = 'harbor.status.im'
IMAGE_NAME = 'wakuorg/storenode-messages-counter'
IMAGE_DEFAULT_TAG = "${env.GIT_COMMIT.take(8)}"
}
stages {
stage('Build') {
steps { script {
image = docker.build(
"${DOCKER_REGISTRY}/${IMAGE_NAME}:${IMAGE_DEFAULT_TAG}",
"--build-arg='commit=${GIT_COMMIT}' .",
)
} }
}
stage('Deploy') {
when { expression { params.IMAGE_TAG != '' } }
steps { script {
withDockerRegistry([
credentialsId: 'harbor-telemetry-robot',
url: 'https://${DOCKER_REGISTRY}',
]) {
image.push(params.IMAGE_TAG)
}
} }
}
}
post {
cleanup { cleanWs() }
}
}