From 6d79beeeb6d4a00e347c43fe03e1fc75a0061391 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Mon, 21 Jun 2021 13:26:55 -0400 Subject: [PATCH] Build (And Publish) Docker Image --- Dockerfile | 21 +++++++++++++++++++++ Jenkinsfile | 47 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 14 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..51ff52f04 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:bullseye + +# Copy DEB +ADD ./out/minecraft-pi-reborn-server_*~bullseye_amd64.deb /root + +# Install +RUN \ + apt-get update && \ + apt-get install -y tini && \ + (dpkg -i /root/*.deb || :) && \ + apt-get --fix-broken install -y && \ + rm -f /root/*.deb && \ + rm -rf /var/lib/apt/lists/* + +# Setup Working Directory +RUN mkdir /data +WORKDIR /data + +# Setup Entrypoint +ENTRYPOINT ["/usr/bin/tini", "--"] +CMD ["minecraft-pi-reborn-server"] diff --git a/Jenkinsfile b/Jenkinsfile index 56d995c80..c28b9253a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,33 +1,52 @@ pipeline { agent none stages { - stage('Build (Debian Bullseye)') { + stage('Debian Bullseye') { agent { docker { image 'debian:bullseye' + args '-v /var/run/docker.sock:/var/run/docker.sock' } } - steps { - sh './scripts/ci/run.sh' - } - post { - success { - archiveArtifacts artifacts: 'out/*.deb', fingerprint: true + stages { + stage('Build') { + steps { + sh './scripts/ci/run.sh' + } + post { + success { + archiveArtifacts artifacts: 'out/*.deb', fingerprint: true + } + } + } + stage('Publish') { + steps { + sh 'apt-get update && apt-get install -y docker.io' + sh 'docker build --no-cache --tag thebrokenrail/minecraft-pi-reborn-server .' + withCredentials([usernamePassword(credentialsId: 'docker_hub_login', usernameVariable: 'DOCKER_HUB_USERNAME', passwordVariable: 'DOCKER_HUB_PASSWORD')]) { + sh 'docker login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}"' + } + sh 'docker push thebrokenrail/minecraft-pi-reborn-server' + } } } } - stage('Build (Debian Buster)') { + stage('Debian Buster') { agent { docker { image 'debian:buster' } } - steps { - sh './scripts/ci/run.sh' - } - post { - success { - archiveArtifacts artifacts: 'out/*.deb', fingerprint: true + stages { + stage('Build') { + steps { + sh './scripts/ci/run.sh' + } + post { + success { + archiveArtifacts artifacts: 'out/*.deb', fingerprint: true + } + } } } }