7 changed files with 169 additions and 40 deletions
-
7.env
-
32Dockerfile
-
71Jenkinsfile
-
22build.sh
-
48develop.sh
-
23docker-compose-build.yml
-
6docker-compose.yml
@ -0,0 +1,7 @@ |
|||||
|
#!/bin/sh |
||||
|
CCG_PROJECT=devpi |
||||
|
DOCKER_DEVPI_SERVER_VERSION=4.1.1 |
||||
|
DOCKER_DEVPI_CLIENT_VERSION=2.7.0 |
||||
|
DOCKER_DEVPI_WEB_VERSION=3.1.1 |
||||
|
DOCKER_ROUTE |
||||
|
BRANCH_NAME |
||||
@ -0,0 +1,71 @@ |
|||||
|
#!groovy |
||||
|
|
||||
|
node { |
||||
|
def deployable_branches = ["master"] |
||||
|
|
||||
|
stage('Checkout') { |
||||
|
checkout scm |
||||
|
} |
||||
|
|
||||
|
dockerStage('Build') { |
||||
|
echo "Branch is: ${env.BRANCH_NAME}" |
||||
|
echo "Build is: ${env.BUILD_NUMBER}" |
||||
|
sh(''' |
||||
|
./develop.sh sanity |
||||
|
./develop.sh build prod |
||||
|
./develop.sh build latest |
||||
|
''') |
||||
|
} |
||||
|
|
||||
|
if (deployable_branches.contains(env.BRANCH_NAME)) { |
||||
|
|
||||
|
dockerStage('Publish') { |
||||
|
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerbot', |
||||
|
usernameVariable: 'DOCKER_USERNAME', |
||||
|
passwordVariable: 'DOCKER_PASSWORD']]) { |
||||
|
sh(""" |
||||
|
docker login -u "${env.DOCKER_USERNAME}" --password="${env.DOCKER_PASSWORD}" |
||||
|
./develop.sh push prod |
||||
|
./develop.sh push latest |
||||
|
""") |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/* |
||||
|
* dockerStage |
||||
|
* |
||||
|
* Custom stage that wraps the stage in timestamps and AnsiColorBuildWrapper |
||||
|
* Prior to exit wrfy is used to kill all running containers and cleanup. |
||||
|
*/ |
||||
|
def dockerStage(String label, |
||||
|
List<String> artifacts=[], |
||||
|
List<String> testResults=[], |
||||
|
Closure body) { |
||||
|
|
||||
|
stage(label) { |
||||
|
try { |
||||
|
timestamps { |
||||
|
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) { |
||||
|
body.call() |
||||
|
} |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
currentBuild.result = 'FAILURE' |
||||
|
throw e |
||||
|
} finally { |
||||
|
for (artifact in artifacts) { |
||||
|
step([$class: 'ArtifactArchiver', artifacts: artifact, fingerprint: false, excludes: null]) |
||||
|
} |
||||
|
for (testResult in testResults) { |
||||
|
step([$class: 'JUnitResultArchiver', testResults: testResult]) |
||||
|
} |
||||
|
sh(''' |
||||
|
/env/bin/wrfy kill-all --force |
||||
|
/env/bin/wrfy scrub --force |
||||
|
''') |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,22 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# Script to build images |
|
||||
# |
|
||||
|
|
||||
# break on error |
|
||||
set -e |
|
||||
set -x |
|
||||
set -a |
|
||||
|
|
||||
DATE=`date +%Y.%m.%d` |
|
||||
DOCKER_DEVPI_VERSION=4.0.0 |
|
||||
|
|
||||
docker-compose build devpi |
|
||||
docker inspect muccg/devpi:latest |
|
||||
|
|
||||
docker tag muccg/devpi:latest muccg/devpi:latest-${DATE} |
|
||||
docker tag muccg/devpi:latest muccg/devpi:${DOCKER_DEVPI_VERSION} |
|
||||
|
|
||||
docker push muccg/devpi:latest |
|
||||
docker push muccg/devpi:latest-${DATE} |
|
||||
docker push muccg/devpi:${DOCKER_DEVPI_VERSION} |
|
||||
@ -0,0 +1,48 @@ |
|||||
|
#!/bin/sh |
||||
|
set +x |
||||
|
set -e |
||||
|
|
||||
|
: "${CCG_DOCKER_ORG:=muccg}" |
||||
|
: "${CCG_COMPOSER:=ccg-composer}" |
||||
|
: "${CCG_COMPOSER_VERSION:=latest}" |
||||
|
: "${CCG_PIP_PROXY=0}" |
||||
|
: "${CCG_HTTP_PROXY=0}" |
||||
|
|
||||
|
export CCG_DOCKER_ORG CCG_COMPOSER CCG_COMPOSER_VERSION CCG_PIP_PROXY CCG_HTTP_PROXY |
||||
|
|
||||
|
# ensure we have an .env file |
||||
|
ENV_FILE_OPT='' |
||||
|
if [ -f .env ]; then |
||||
|
ENV_FILE_OPT='--env-file .env' |
||||
|
set +e |
||||
|
. ./.env > /dev/null 2>&1 |
||||
|
set -e |
||||
|
else |
||||
|
echo ".env file not found, settings such as project name and proxies will not be set" |
||||
|
fi |
||||
|
|
||||
|
# Pass through the ip of the host if we can |
||||
|
# There is no docker0 interface on Mac OS, so don't do any proxy detection |
||||
|
if [ "$(uname)" != "Darwin" ]; then |
||||
|
set +e |
||||
|
DOCKER_ROUTE=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+') |
||||
|
set -e |
||||
|
export DOCKER_ROUTE |
||||
|
fi |
||||
|
|
||||
|
TTY_OPTS= |
||||
|
if [ -t 0 ]; then |
||||
|
TTY_OPTS='--interactive --tty' |
||||
|
fi |
||||
|
|
||||
|
ENV_OPTS="$(env | sort | cut -d= -f1 | grep "^CCG_[a-zA-Z0-9_]*$" | awk '{print "-e", $1}')" |
||||
|
# shellcheck disable=SC2086 disable=SC2048 |
||||
|
docker run --rm ${TTY_OPTS} ${ENV_FILE_OPT} \ |
||||
|
${ENV_OPTS} \ |
||||
|
-v /etc/timezone:/etc/timezone:ro \ |
||||
|
-v /var/run/docker.sock:/var/run/docker.sock \ |
||||
|
-v "$(pwd)":"$(pwd)" \ |
||||
|
-v "${HOME}"/.docker:/data/.docker \ |
||||
|
-w "$(pwd)" \ |
||||
|
"${CCG_DOCKER_ORG}"/"${CCG_COMPOSER}":"${CCG_COMPOSER_VERSION}" \ |
||||
|
"$@" |
||||
@ -0,0 +1,23 @@ |
|||||
|
version: '2' |
||||
|
services: |
||||
|
|
||||
|
dev: |
||||
|
build: |
||||
|
context: ./ |
||||
|
args: |
||||
|
ARG_DEVPI_SERVER_VERSION: ${DOCKER_DEVPI_SERVER_VERSION} |
||||
|
ARG_DEVPI_WEB_VERSION: ${DOCKER_DEVPI_WEB_VERSION} |
||||
|
ARG_DEVPI_CLIENT_VERSION: ${DOCKER_DEVPI_CLIENT_VERSION} |
||||
|
image: muccg/devpi:${GIT_BRANCH} |
||||
|
|
||||
|
prod: |
||||
|
extends: |
||||
|
file: docker-compose-build.yml |
||||
|
service: dev |
||||
|
image: muccg/devpi:${DOCKER_DEVPI_SERVER_VERSION} |
||||
|
|
||||
|
latest: |
||||
|
extends: |
||||
|
file: docker-compose-build.yml |
||||
|
service: dev |
||||
|
image: muccg/devpi:latest |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue