├── Jenkinsfile ├── LICENSE ├── README.md ├── alpine ├── Dockerfile ├── Jenkinsfile ├── README.md ├── imagescripts │ ├── createuser.sh │ ├── dockeruser.sh │ └── dockerwait.sh └── settings.groovy ├── build ├── buildImage.groovy └── releaseImage.groovy ├── centos ├── Dockerfile ├── Jenkinsfile └── settings.groovy └── ubuntu ├── Dockerfile ├── Jenkinsfile └── settings.groovy /Jenkinsfile: -------------------------------------------------------------------------------- 1 | /** Jenkins 2.0 Buildfile 2 | * 3 | * Master Jenkins 2.0 can be started by typing: 4 | * docker run -d -p 8090:8080 --name jenkins blacklabelops/jenkins 5 | * 6 | * Slave 'docker' can be started by typing: 7 | * docker run -d -v /var/run/docker.sock:/var/run/docker.sock --link jenkins:jenkins -e "SWARM_CLIENT_LABELS=docker" blacklabelops/swarm-dockerhost 8 | **/ 9 | node { 10 | checkout scm 11 | stage 'Build & Test Images' 12 | parallel( 13 | "image-alpine": { load 'alpine/Jenkinsfile' }, 14 | "image-centos": { load 'centos/Jenkinsfile' }, 15 | "image-ubuntu": { load 'ubuntu/Jenkinsfile' } 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Steffen Bleul 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Supported Tags And Respective Dockerfile Links 2 | 3 | | Base Image | Tag | Dockerfile | Readme | 4 | |--------------|--------------|------------|--------| 5 | | blacklabelops/alpine | latest, 3.8 | [Dockerfile](alpine/Dockerfile) | [README.md](alpine/README.md) | 6 | | blacklabelops/centos | latest, 7, 7.4 , 7.4.1708 | [Dockerfile](centos/Dockerfile) | [README.md](README.md) | 7 | | blacklabelops/ubuntu | latest, 18, 18.04 | [Dockerfile](ubuntu/Dockerfile) | [README.md](README.md) | 8 | 9 | # blacklabelops/alpine 10 | 11 | [![Docker Stars](https://img.shields.io/docker/stars/blacklabelops/alpine.svg)](https://hub.docker.com/r/blacklabelops/alpine/) [![Docker Pulls](https://img.shields.io/docker/pulls/blacklabelops/alpine.svg)](https://hub.docker.com/r/blacklabelops/alpine/) 12 | 13 | Blacklabelops Alpine Base Image 14 | 15 | * Includes repository updates 16 | * tini: Zombie Process Reaper 17 | * su-exec: Execute processes as different user 18 | * wait-for-it: Waiting for available server ports. 19 | * Feature Script: Runtime user definition with environment variables. 20 | 21 | [README.de](alpine/README.md) 22 | 23 | [Dockerhub Repository](https://hub.docker.com/r/blacklabelops/alpine/) 24 | 25 | # blacklabelops/centos 26 | 27 | [![Docker Stars](https://img.shields.io/docker/stars/blacklabelops/centos.svg)](https://hub.docker.com/r/blacklabelops/centos/) [![Docker Pulls](https://img.shields.io/docker/pulls/blacklabelops/centos.svg)](https://hub.docker.com/r/blacklabelops/centos/) 28 | 29 | * Includes updates 30 | 31 | ## Build the Image 32 | 33 | ~~~~ 34 | $ cd centos && docker build -t blacklabelops/centos . 35 | ~~~~ 36 | 37 | ## Run the Image 38 | 39 | ~~~~ 40 | $ docker run -it --rm blacklabelops/centos bash 41 | ~~~~ 42 | 43 | # blacklabelops/ubuntu 44 | 45 | [![Docker Stars](https://img.shields.io/docker/stars/blacklabelops/ubuntu.svg)](https://hub.docker.com/r/blacklabelops/ubuntu/) [![Docker Pulls](https://img.shields.io/docker/pulls/blacklabelops/ubuntu.svg)](https://hub.docker.com/r/blacklabelops/ubuntu/) 46 | 47 | * Includes updates 48 | 49 | ## Build the Image 50 | 51 | ~~~~ 52 | $ cd ubuntu && docker build -t blacklabelops/ubuntu . 53 | ~~~~ 54 | 55 | ## Run the Image 56 | 57 | ~~~~ 58 | $ docker run -it --rm blacklabelops/ubuntu bash 59 | ~~~~ 60 | -------------------------------------------------------------------------------- /alpine/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | ARG BUILD_DATE=undefined 4 | 5 | ENV BLACKLABELOPS_HOME=/var/blacklabelops \ 6 | DOCKERIZE_VERSION=v0.6.0 7 | 8 | RUN apk upgrade --update && \ 9 | apk add \ 10 | bash \ 11 | tzdata \ 12 | vim \ 13 | tini \ 14 | su-exec \ 15 | gzip \ 16 | tar \ 17 | wget \ 18 | curl && \ 19 | # Network fix 20 | echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ 21 | # Blacklabelops Feature Script Folder 22 | mkdir -p ${BLACKLABELOPS_HOME} && \ 23 | # Install dockerize 24 | wget -O /tmp/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz && \ 25 | tar -C /usr/local/bin -xzvf /tmp/dockerize.tar.gz && \ 26 | # Clean up 27 | apk del curl \ 28 | wget && \ 29 | rm -rf /var/cache/apk/* && \ 30 | rm -rf /tmp/* && \ 31 | rm -rf /var/log/* 32 | 33 | COPY imagescripts/ ${BLACKLABELOPS_HOME}/ 34 | COPY imagescripts/dockerwait.sh /usr/bin/dockerwait 35 | 36 | LABEL maintainer="Steffen Bleul " \ 37 | com.blacklabelops.maintainer.name="Steffen Bleul" \ 38 | com.blacklabelops.maintainer.email="sbl@blacklabelops.com" \ 39 | com.blacklabelops.support="https://www.hipchat.com/gEorzhvnI" \ 40 | com.blacklabelops.image.os="alpine" \ 41 | com.blacklabelops.image.osversion="3.7" \ 42 | com.blacklabelops.image.name.alpine="alpine-base-image" \ 43 | com.blacklabelops.image.builddate.alpine=${BUILD_DATE} 44 | -------------------------------------------------------------------------------- /alpine/Jenkinsfile: -------------------------------------------------------------------------------- 1 | /** Jenkins 2.0 Buildfile 2 | * 3 | * Master Jenkins 2.0 can be started by typing: 4 | * docker run -d -p 8090:8080 --name jenkins blacklabelops/jenkins 5 | * 6 | * Slave 'docker' can be started by typing: 7 | * docker run -d -v /var/run/docker.sock:/var/run/docker.sock --link jenkins:jenkins -e "SWARM_CLIENT_LABELS=docker" blacklabelops/swarm-dockerhost 8 | **/ 9 | 10 | node('docker') { 11 | checkout scm 12 | job = load 'build/buildImage.groovy' 13 | settings = load 'alpine/settings.groovy' 14 | job.buildJobCI(settings.dockerWorkspace,settings.dockerImageName,settings.dockerTags,settings.dockerTestCommands,settings.dockerImages,job.getBranchName()) 15 | } 16 | -------------------------------------------------------------------------------- /alpine/README.md: -------------------------------------------------------------------------------- 1 | # Blacklabelops Docker Base Image 2 | 3 | [![Docker Stars](https://img.shields.io/docker/stars/blacklabelops/alpine.svg)](https://hub.docker.com/r/blacklabelops/alpine/) [![Docker Pulls](https://img.shields.io/docker/pulls/blacklabelops/alpine.svg)](https://hub.docker.com/r/blacklabelops/alpine/) 4 | 5 | Alpine images are smaller than full distributions, e.g. CentOS. This is a base image with some tweaks based on the official alpine image on Dockerhub. 6 | 7 | Image Features: 8 | 9 | * Includes repository updates 10 | * tini: Zombie Process Reaper 11 | * su-exec: Execute processes as different user 12 | * wait-for-it: Waiting for available server ports. 13 | * Feature Script: Runtime user definition with environment variables. 14 | 15 | # Build the Image 16 | 17 | ~~~~ 18 | $ cd alpine && docker build -t blacklabelops/alpine . 19 | ~~~~ 20 | 21 | # Run the Image 22 | 23 | ~~~~ 24 | $ docker run -it --rm blacklabelops/alpine bash 25 | ~~~~ 26 | 27 | # Blacklabelops Dockerwait Feature 28 | 29 | The Blacklabelops Dockerwait Feature is a script for polling server ports. This is mandatory when you want to wait for other containers starting web servers or databases. 30 | 31 | You can define a the waiting parameters with the enviromnemt variables: 32 | 33 | * `DOCKER_WAIT_HOST`: The host to poll. Mandatory! 34 | * `DOCKER_WAIT_PORT`: The port to poll Mandatory! 35 | * `DOCKER_WAIT_TIMEOUT`: The timeout in seconds. Optional! Default: 60 36 | * `DOCKER_WAIT_INTERVAL`: The polling interval in seconds. Optional! Default:5 37 | 38 | Example waiting for a postgresql database: 39 | 40 | First start the polling container: 41 | 42 | ~~~~ 43 | $ docker network create testnetwork 44 | $ docker run \ 45 | --net testnetwork \ 46 | -e "DOCKER_WAIT_HOST=postgres" \ 47 | -e "DOCKER_WAIT_PORT=5432" \ 48 | blacklabelops/alpine dockerwait 49 | ~~~~ 50 | 51 | > Waits at most 60 seconds for the database. 52 | 53 | Secondly start the database: 54 | 55 | ~~~~ 56 | $ docker run -d --name postgres \ 57 | --net testnetwork --hostname postgres \ 58 | -e 'POSTGRES_USER=postgres' \ 59 | -e 'POSTGRES_PASSWORD=postgres' \ 60 | postgres:9.4 61 | ~~~~ 62 | 63 | > Starts postgres database under hostname `postgres` in docker network `testnetwork` 64 | 65 | You can integrate this feature inside your entrypoint: 66 | 67 | ~~~~ 68 | #!/bin/bash 69 | 70 | # Use The Feature Script 71 | source /usr/bin/dockerwait 72 | # Executing The Application 73 | exec your_application_command_here 74 | ~~~~ 75 | 76 | > Simple entrypoint.sh script example. 77 | 78 | # Blacklabelops User Feature 79 | 80 | The Blacklabelops User Feature is a script for specifiying the run user of your application with env variables. 81 | The user will be created automatically and can be user inside your entrypoint to start your application using `su-exec`. 82 | 83 | You can define a user for your application at startup with the environment variables: 84 | 85 | * `DOCKER_USER`: The user's name, should match a valid username on your host machine (Default: blacklabelops). 86 | * `DOCKER_USER_ID`: The user's id should match a valid id on your host machine (Default: 1000). 87 | * `DOCKER_USERGROUP`: The user's groupname, should match a valid groupname on your host machine (Default: blacklabelops). 88 | * `DOCKER_USERGROUP_ID`: The user's groupid, should match a valid goup id on your host machine (Default: 1000). 89 | 90 | Example Use Case: 91 | 92 | ~~~~ 93 | $ docker run \ 94 | -e "DOCKER_USER=YourUser" \ 95 | -e "DOCKER_USER_ID=2000" \ 96 | -e "DOCKER_USERGROUP=YourGroup" \ 97 | -e "DOCKER_USERGROUP_ID=2000" \ 98 | blacklabelops/alpine ./var/blacklabelops/createuser.sh 99 | ~~~~ 100 | 101 | In order to make this work you will have to hook this script in your individual entrypoint script: 102 | 103 | ~~~~ 104 | #!/bin/bash 105 | 106 | # Include The Feature Script 107 | source /var/blacklabelops/dockeruser.sh 108 | # Create The User 109 | dockerUser 110 | # Print User Information 111 | printUserInfo 112 | # Executing The Application 113 | exec su-exec $CURRENT_DOCKER_USER your_application_command_here 114 | ~~~~ 115 | 116 | > Simple entrypoint.sh script example. 117 | 118 | # Using tini 119 | 120 | Tini is used to wrap your images entrypoint! 121 | 122 | More information: [krallin/tini](https://github.com/krallin/tini) 123 | 124 | Example: 125 | 126 | ~~~~ 127 | ENTRYPOINT ["/sbin/tini","--","/yourpath/docker-entrypoint.sh"] 128 | ~~~~ 129 | 130 | > Will start your entrypoint under tini process management. 131 | 132 | # Using su-exec 133 | 134 | Su-Exec C reimplementation of gosu! Simplified sudo to exec processes under different users. 135 | 136 | More information: [ncopa/su-exec](https://github.com/ncopa/su-exec) 137 | 138 | Use su-exec in your individual entrypoint script: 139 | 140 | ~~~~ 141 | #!/bin/bash 142 | 143 | # Executing The Application 144 | exec su-exec your_user your_application_command_here 145 | ~~~~ 146 | 147 | > Simple entrypoint.sh script example. 148 | 149 | # Using dockerize 150 | 151 | Dockerize is a tool that allows to wait for available ports and sites on the network. 152 | 153 | More information: [jwilder/dockerize](https://github.com/jwilder/dockerize) 154 | 155 | Example waiting for a database and website: 156 | 157 | ~~~~ 158 | $ dockerize -wait tcp://db:5432 -wait http://web:80 -timeout 10s 159 | ~~~~ 160 | 161 | > The parameter `-wait` can be used arbitrary times. 162 | 163 | # Build the Image 164 | 165 | ~~~~ 166 | $ docker build -t blacklabelops/alpine . 167 | ~~~~ 168 | 169 | # Run the Image 170 | 171 | ~~~~ 172 | $ docker run -it --rm blacklabelops/alpine bash 173 | ~~~~ 174 | 175 | # Support 176 | 177 | Leave a message and ask questions on Hipchat: [blacklabelops/support](https://www.hipchat.com/gEorzhvnI) 178 | -------------------------------------------------------------------------------- /alpine/imagescripts/createuser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | 5 | readonly CUR_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd) 6 | 7 | source $CUR_DIR/dockeruser.sh 8 | 9 | dockerUser 10 | printUserInfo 11 | -------------------------------------------------------------------------------- /alpine/imagescripts/dockeruser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | 5 | function createDockerUserGroup { 6 | local groupname=$1 7 | local groupid=$2 8 | addgroup -g $groupid $groupname 9 | } 10 | 11 | function createDockerUser { 12 | local username=$1 13 | local userid=$2 14 | local groupname=$3 15 | adduser -G $groupname -s /bin/bash -u $userid -h /home/$username -S $username 16 | } 17 | 18 | function dockerUser { 19 | createDockerUserGroup $CURRENT_DOCKER_GROUP $CURRENT_DOCKER_GROUP_ID 20 | createDockerUser $CURRENT_DOCKER_USER $CURRENT_DOCKER_USER_ID $CURRENT_DOCKER_GROUP 21 | } 22 | 23 | function printUserInfo { 24 | echo "Docker User: "$(id $CURRENT_DOCKER_USER) 25 | } 26 | 27 | function dockerUserInit { 28 | local default_user=$1 29 | local default_user_id=$2 30 | local default_group=$3 31 | local default_group_id=$4 32 | DOCKER_DEFAULT_USER=${default_user:-blacklabelops} 33 | DOCKER_DEFAULT_USER_ID=${default_user_id:-1000} 34 | DOCKER_DEFAULT_GROUP=${default_group:-blacklabelops} 35 | DOCKER_DEFAULT_GROUP_ID=${default_group_id:-1000} 36 | 37 | CURRENT_DOCKER_USER=${DOCKER_USER:-$DOCKER_DEFAULT_USER} 38 | CURRENT_DOCKER_USER_ID=${DOCKER_USER_ID:-$DOCKER_DEFAULT_USER_ID} 39 | CURRENT_DOCKER_GROUP=${DOCKER_USERGROUP:-$DOCKER_DEFAULT_GROUP} 40 | CURRENT_DOCKER_GROUP_ID=${DOCKER_USERGROUP_ID:-$DOCKER_DEFAULT_GROUP_ID} 41 | } 42 | 43 | dockerUserInit $1 $2 $3 $4 44 | -------------------------------------------------------------------------------- /alpine/imagescripts/dockerwait.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | 5 | function dockerWaitInit { 6 | CURRENT_DOCKER_WAIT_HOST=$DOCKER_WAIT_HOST 7 | CURRENT_DOCKER_WAIT_PORT=$DOCKER_WAIT_PORT 8 | CURRENT_DOCKER_WAIT_TIMEOUT=${DOCKER_WAIT_TIMEOUT:-60} 9 | CURRENT_DOCKER_WAIT_INTERVAL=${DOCKER_WAIT_INTERVAL:-5} 10 | } 11 | 12 | function dockerPoll { 13 | local totalTime=0 14 | while ! nc $CURRENT_DOCKER_WAIT_HOST $CURRENT_DOCKER_WAIT_PORT