Attempt at adding Jenkins CI
All checks were successful
ecodash/pipeline/head This commit looks good
All checks were successful
ecodash/pipeline/head This commit looks good
This commit is contained in:
parent
4b3af653b8
commit
33f09c93bd
|
@ -1,69 +0,0 @@
|
|||
pipeline:
|
||||
|
||||
build-and-format:
|
||||
image: golang
|
||||
commands:
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||
- go mod tidy
|
||||
- golangci-lint run
|
||||
- env GOOS=linux GOARCH=amd64 go build -o ecodash-x86 src/main/main.go
|
||||
- env GOOS=linux GOARCH=arm go build -o ecodash-arm src/main/main.go
|
||||
- apt-get update; apt-get upgrade -y; apt-get install zip -y
|
||||
- mv ecodash-x86 ecodash; zip -r ecodash-x86.zip templates ecodash; mv ecodash ecodash-x86
|
||||
- mv ecodash-arm ecodash; zip -r ecodash-arm.zip templates ecodash; mv ecodash ecodash-arm
|
||||
- zip templates.zip -r templates
|
||||
|
||||
upload-debug:
|
||||
image: vividboarder/drone-webdav
|
||||
settings:
|
||||
file: { ecodash-x86,ecodash-arm,templates.zip }
|
||||
destination:
|
||||
from_secret: webdav_destination
|
||||
username:
|
||||
from_secret: webdav_username
|
||||
password:
|
||||
from_secret: webdav_password
|
||||
attempts: 5
|
||||
|
||||
gitea-publish:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
base_url: https://git.massivebox.net
|
||||
files:
|
||||
- ecodash-x86.zip
|
||||
- ecodash-arm.zip
|
||||
api_key:
|
||||
from_secret: auth_token
|
||||
title: ${CI_COMMIT_TAG}
|
||||
when:
|
||||
event: tag
|
||||
|
||||
docker-unstable:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: git.massivebox.net
|
||||
repo: git.massivebox.net/ecodash/ecodash
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tag: unstable
|
||||
username: massivebox
|
||||
password:
|
||||
from_secret: auth_token
|
||||
context: .woodpecker
|
||||
dockerfile: .woodpecker/Dockerfile-woodpecker
|
||||
when:
|
||||
event: [ push, pull_request, deployment ]
|
||||
|
||||
docker-tag:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: git.massivebox.net
|
||||
repo: git.massivebox.net/ecodash/ecodash
|
||||
platforms: linux/amd64,linux/arm64
|
||||
auto_tag: true
|
||||
username: massivebox
|
||||
password:
|
||||
from_secret: auth_token
|
||||
context: .woodpecker
|
||||
dockerfile: .woodpecker/Dockerfile-woodpecker
|
||||
when:
|
||||
event: tag
|
|
@ -1,11 +0,0 @@
|
|||
FROM debian:latest
|
||||
|
||||
WORKDIR /app
|
||||
COPY ./setup.sh ./setup.sh
|
||||
|
||||
RUN apt-get update; apt-get upgrade -y; apt-get install zip curl -y && \
|
||||
curl https://cloud.massivebox.net/api/public/dl/fLgOAQNc -o templates.zip && unzip templates.zip && rm templates.zip && \
|
||||
chmod +x setup.sh && ./setup.sh && rm setup.sh && \
|
||||
chmod +x app
|
||||
|
||||
CMD ["./app"]
|
|
@ -1,19 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
ARCH=$(arch)
|
||||
|
||||
# This is a workaround to Woodpecker's inability to give files it has just built to Docker BuildX to build new images.
|
||||
# After compiling the binaries in the "build-and-format" step of woodpecker.yml, we upload them to the cloud and fetch them from here.
|
||||
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
echo "detected amd64"
|
||||
curl https://cloud.massivebox.net/api/public/dl/uZaDQXAa -o app
|
||||
elif [ "$ARCH" = "aarch64" ]; then
|
||||
echo "deteched arm"
|
||||
curl https://cloud.massivebox.net/api/public/dl/EhM62nhf -o app
|
||||
else
|
||||
echo "unsupported architecture"
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
|
@ -1,69 +0,0 @@
|
|||
pipeline:
|
||||
|
||||
build-and-format:
|
||||
image: golang
|
||||
commands:
|
||||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
|
||||
- go mod tidy
|
||||
- golangci-lint run
|
||||
- env GOOS=linux GOARCH=amd64 go build -o ecodash-x86 src/main/main.go
|
||||
- env GOOS=linux GOARCH=arm go build -o ecodash-arm src/main/main.go
|
||||
- apt-get update; apt-get upgrade -y; apt-get install zip -y
|
||||
- mv ecodash-x86 ecodash; zip -r ecodash-x86.zip templates ecodash; mv ecodash ecodash-x86
|
||||
- mv ecodash-arm ecodash; zip -r ecodash-arm.zip templates ecodash; mv ecodash ecodash-arm
|
||||
- zip templates.zip -r templates
|
||||
|
||||
upload-debug:
|
||||
image: vividboarder/drone-webdav
|
||||
settings:
|
||||
file: { ecodash-x86,ecodash-arm,templates.zip }
|
||||
destination:
|
||||
from_secret: webdav_destination
|
||||
username:
|
||||
from_secret: webdav_username
|
||||
password:
|
||||
from_secret: webdav_password
|
||||
attempts: 5
|
||||
|
||||
gitea-publish:
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
base_url: https://git.massivebox.net
|
||||
files:
|
||||
- ecodash-x86.zip
|
||||
- ecodash-arm.zip
|
||||
api_key:
|
||||
from_secret: auth_token
|
||||
title: ${CI_COMMIT_TAG}
|
||||
when:
|
||||
event: tag
|
||||
|
||||
docker-unstable:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: git.massivebox.net
|
||||
repo: git.massivebox.net/ecodash/ecodash
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tag: unstable
|
||||
username: massivebox
|
||||
password:
|
||||
from_secret: auth_token
|
||||
context: .woodpecker
|
||||
dockerfile: .woodpecker/Dockerfile-woodpecker
|
||||
when:
|
||||
event: [ push, pull_request, deployment ]
|
||||
|
||||
docker-tag:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: git.massivebox.net
|
||||
repo: git.massivebox.net/ecodash/ecodash
|
||||
platforms: linux/amd64,linux/arm64
|
||||
auto_tag: true
|
||||
username: massivebox
|
||||
password:
|
||||
from_secret: auth_token
|
||||
context: .woodpecker
|
||||
dockerfile: .woodpecker/Dockerfile-woodpecker
|
||||
when:
|
||||
event: tag
|
77
Jenkinsfile
vendored
Normal file
77
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
pipeline {
|
||||
|
||||
agent any
|
||||
|
||||
environment {
|
||||
USER='placeholder'
|
||||
PASSWORD='placeholder'
|
||||
DOCKER_REGISTRY='git.massivebox.net'
|
||||
BUILDER_NAME='mbuilder'
|
||||
SERVICE='ecodash/ecodash'
|
||||
TAG='latest'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Run linter and build') {
|
||||
agent { docker { image 'golang' } }
|
||||
steps {
|
||||
git url: 'https://git.massivebox.net/ecodash/ecodash'
|
||||
sh 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin'
|
||||
sh 'go mod tidy'
|
||||
sh 'golangci-lint run'
|
||||
sh 'env GOOS=linux GOARCH=amd64 go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-x86'
|
||||
sh 'env GOOS=linux GOARCH=arm go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-arm'
|
||||
stash includes: 'jenkins/Dockerfile', name: 'dockerfile'
|
||||
stash includes: 'templates/**', name: 'templates'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Build x86 container') {
|
||||
steps {
|
||||
unstash 'dockerfile'
|
||||
unstash 'ecodash-x86'
|
||||
unstash 'templates'
|
||||
sh 'docker build -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prepare buildx') {
|
||||
steps {
|
||||
sh """
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
|
||||
docker context create $BUILDER_NAME
|
||||
docker context use $BUILDER_NAME
|
||||
docker buildx create $BUILDER_NAME
|
||||
docker buildx use $BUILDER_NAME
|
||||
docker buildx inspect --bootstrap
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build arm container') {
|
||||
steps {
|
||||
unstash 'dockerfile'
|
||||
unstash 'ecodash-arm'
|
||||
unstash 'templates'
|
||||
sh 'docker buildx build --platform linux/arm64 -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// cleanup
|
||||
sh """
|
||||
docker context rm -f $BUILDER_NAME
|
||||
docker buildx use default
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
0
jenkins/Dockerfile
Normal file
0
jenkins/Dockerfile
Normal file
76
jenkins/Jenkinsfile
vendored
Normal file
76
jenkins/Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
pipeline {
|
||||
|
||||
agent any
|
||||
|
||||
environment {
|
||||
USER='user'
|
||||
PASSWORD='password'
|
||||
DOCKER_REGISTRY='git.massivebox.net'
|
||||
BUILDER_NAME='mbuilder'
|
||||
SERVICE='ecodash/ecodash'
|
||||
TAG='latest'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Run linter and build') {
|
||||
agent { docker { image 'golang' } }
|
||||
steps {
|
||||
git url: 'https://git.massivebox.net/ecodash/ecodash'
|
||||
//sh 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin'
|
||||
sh 'go mod tidy'
|
||||
//sh 'golangci-lint run'
|
||||
sh 'env GOOS=linux GOARCH=amd64 go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-x86'
|
||||
sh 'env GOOS=linux GOARCH=arm go build -o app src/main/main.go'
|
||||
stash includes: 'app', name: 'ecodash-arm'
|
||||
stash includes: 'templates/**', name: 'templates'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stage('Build x86 container') {
|
||||
steps {
|
||||
sh 'curl -L -o Dockerfile https://pasty.nikko.cf/UYU39i/raw'
|
||||
unstash 'ecodash-x86'
|
||||
unstash 'templates'
|
||||
sh 'docker build -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prepare buildx') {
|
||||
steps {
|
||||
sh """
|
||||
docker run --privileged --rm tonistiigi/binfmt --install all
|
||||
|
||||
docker context create $BUILDER_NAME
|
||||
docker context use $BUILDER_NAME
|
||||
docker buildx create $BUILDER_NAME
|
||||
docker buildx use $BUILDER_NAME
|
||||
docker buildx inspect --bootstrap
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build arm container') {
|
||||
steps {
|
||||
sh 'curl -L -o Dockerfile https://pasty.nikko.cf/UYU39i/raw'
|
||||
unstash 'ecodash-arm'
|
||||
unstash 'templates'
|
||||
sh 'docker buildx build --platform linux/arm64 -t $DOCKER_REGISTRY/$SERVICE:$TAG .'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// cleanup
|
||||
sh """
|
||||
docker context rm -f $BUILDER_NAME
|
||||
docker buildx use default
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue