Skip to content

Commit

Permalink
Add jenkinsio dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
olblak committed Sep 2, 2017
1 parent 67cccab commit 8b921b0
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
]

def dockerImage
def imageName = 'jenkinsciinfra/jenkinsio'
def azure_storageaccount_name = 'prodjenkinsio'

if (!env.CHANGE_ID) {
if (env.BRANCH_NAME == null) {
projectProperties.add(pipelineTriggers([cron('H/30 * * * *')]))
Expand Down Expand Up @@ -74,6 +78,16 @@ try {
'''
}
}
stage('Build Docker Image') {
timeout(60) {
dir('docker') {
sh 'git rev-parse HEAD > GIT_COMMIT'
shortCommit = readFile('GIT_COMMIT').take(6)
echo "Creating the container ${imageName}:latest"
dockerImage = docker.build("${imageName}:latest", "--label commit_id=${shortCommit} --label build_id=${env.BUILD_ID}")
}
}
}

stage('Archive site') {
/* The `archive` task inside the Gradle build should be creating a zip file
Expand All @@ -99,6 +113,15 @@ try {
}
}
}

if (infra.isTrusted()) {
stage('Publish Docker image') {
timestamps { dockerImage.push() }
}
stage('Publish on Azure file') {
sh './scripts/az storage file upload-batch --account-name ${azure_storageaccount_name} -d jenkinsio -s /data/build/_site'
}
}
}
catch (exc) {
echo "Caught: ${exc}"
Expand Down
10 changes: 10 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Cfr IEP-006

FROM nginx:1.13

LABEL \
Description="www.jenkins.io website" \
Project="https://github.com/jenkins-infra/jenkins.io" \
Maintainer="[email protected]"

COPY nginx.conf /etc/nginx/nginx.conf
32 changes: 32 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
user root; # Azure File storage on Kubernetes do not support other users than root
# but is the only azure blob storage that support many read/write.
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}
31 changes: 31 additions & 0 deletions scripts/az
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# This script is meant to be added to the PATH so the latest azure-cli is
# always ready to use

set +x

CONTAINER_NAME=azuresdk/azure-cli-python:0.1.5

pull_container() {
docker pull ${CONTAINER_NAME}
}

# Pull down the container if we don't already have it
docker inspect ${CONTAINER_NAME} > /dev/null 2>&1
if [ $? -ne 0 ]; then
pull_container
fi;

# http://blog.dscpl.com.au/2015/12/unknown-user-when-running-docker.html
# Passing LOGNAME and USER because the acs component in the azure-cli does some
# user lookup

exec docker run --rm -u "$(id -u):$(id -u)" \
-v "${HOME}/.azure:/.azure" \
-e LOGNAME="$LOGNAME" \
-e USER="$USER" \
-v "$PWD:/data" \
-t \
--workdir=/data \
"${CONTAINER_NAME}" /usr/local/bin/az "$@"

0 comments on commit 8b921b0

Please sign in to comment.