Forked from alirezabonab/setup jenkins, portainer and registry on docker
Created
June 20, 2018 09:53
-
-
Save mort3za/ac0db5968c67e9be967609881435342b to your computer and use it in GitHub Desktop.
docker service with portainer jenkins and registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
DOCKER_PATH=$(which docker) | |
# PORT Number Definition | |
# ---------------------------------------------- | |
# system ports | |
PORT_JENKINS="9110" | |
PORT_PORTAINER="9120" | |
PORT_REGISTRY="5000" | |
echo "docker path is : $DOCKER_PATH \n" | |
echo "jenkins port : $PORT_JENKINS \n" | |
echo "portainer port : $PORT_PORTAINER \n" | |
echo "registry port : $PORT_REGISTRY \n" | |
# PORT Number Definition END! | |
# ---------------------------------------------- | |
# create Network | |
if [ -z "$(docker network ls -q -f name=main)" ]; then | |
echo "\n \n create network main \n" | |
docker network create --driver overlay main | |
fi | |
# create Volumes | |
# ---------------------------------------------- | |
# portainer_data | |
if [ -z "$(docker volume ls -q -f name=portainer_data)" ]; then | |
echo "\n \n create volume portainer_data \n" | |
docker volume create portainer_data | |
fi | |
# jenkins_data | |
if [ -z "$(docker volume ls -q -f name=jenkins_data)" ]; then | |
echo "\n \n create volume jenkins_data \n" | |
docker volume create jenkins_data | |
fi | |
# registry_data | |
if [ -z "$(docker volume ls -q -f name=registry_data)" ]; then | |
echo "\n \n create volume registry_data \n" | |
docker volume create registry_data | |
fi | |
# create Volumes END! | |
# ---------------------------------------------- | |
# create services | |
# ---------------------------------------------- | |
# portainer | |
if [ -n "$(docker service ls -q -f name=portainer)" ]; then | |
echo "\n \n update portainer service.\n" | |
docker service rm portainer | |
fi | |
echo "\n \n create service portainer \n" | |
docker service create --name portainer --publish "$PORT_PORTAINER":9000 --replicas=1 --constraint 'node.role == manager' --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --mount type=volume,src=portainer_data,dst=/data portainer/portainer -H unix:///var/run/docker.sock | |
# registry | |
if [ -n "$(docker service ls -q -f name=registry)" ]; then | |
echo "\n \n update registry service. \n" | |
docker service rm registry | |
fi | |
echo "\n \n create service registry \n" | |
docker service create --name registry --network main --mount type=volume,src=registry_data,dst=/var/lib/registry --publish "$PORT_REGISTRY":5000 registry:2 | |
# Jenkins | |
if [ -n "$(docker service ls -q -f name=jenkins)" ]; then | |
echo "\n \n remove jenkins service.\n" | |
docker service rm jenkins | |
fi | |
echo "\n \n create service jenkins \n" | |
docker service create --name jenkins --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src="$DOCKER_PATH",dst=/usr/bin/docker --mount type=volume,src=jenkins_data,dst=/var/jenkins_home --mount type=bind,src=/usr/lib/x86_64-linux-gnu/libltdl.so.7,dst=/usr/lib/libltdl.so.7 --publish "$PORT_JENKINS":8080 --publish 50000:50000 --name jenkins sunnystatue/docker_in_jenkins | |
# create services END! | |
# ---------------------------------------------- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment