diff --git a/README.md b/README.md index 25e76c4..d444b95 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,19 @@ ## build +### state + + +### build manually + ``` docker build --pull=true -t pgollor/jenkins-slave ./docker/main/ docker build --pull=true -t pgollor/jenkins-slave-arduino ./docker/arduino/ ``` + +## usage +At fist start pleas execute `install.sh` to generate the config file and data directory. +After that you should modify the `slave.conf` file and can start the container with: +``` +docker-compse up -d --remove-orphans +``` diff --git a/docker-compose.yml b/docker-compose.yml index 97592aa..982efc6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: jenkins-slave1: - image: pgollor/jenkins-slave + image: pgollor/jenkins-slave-ssh mem_limit: 4g restart: always environment: diff --git a/docker/main/Dockerfile b/docker/main/Dockerfile deleted file mode 100644 index 39199f5..0000000 --- a/docker/main/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM jenkinsci/ssh-slave -LABEL MAINTAINER="Pascal Gollor " - -## install dependencies -RUN apt-get -y update \ - && apt-get -y upgrade \ - && rm -rf /var/lib/apt/lists/* - -# install new ssh key -RUN rm /etc/ssh/ssh_host_rsa_key* /etc/ssh/ssh_host_dsa_key* -RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa -RUN ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa - -ENTRYPOINT ["setup-sshd"] diff --git a/docker/ssh/Dockerfile b/docker/ssh/Dockerfile new file mode 100644 index 0000000..39199f5 --- /dev/null +++ b/docker/ssh/Dockerfile @@ -0,0 +1,14 @@ +FROM jenkinsci/ssh-slave +LABEL MAINTAINER="Pascal Gollor " + +## install dependencies +RUN apt-get -y update \ + && apt-get -y upgrade \ + && rm -rf /var/lib/apt/lists/* + +# install new ssh key +RUN rm /etc/ssh/ssh_host_rsa_key* /etc/ssh/ssh_host_dsa_key* +RUN ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +RUN ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa + +ENTRYPOINT ["setup-sshd"] diff --git a/install.sh b/install.sh index ab3fb08..eb58321 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,36 @@ #!/bin/bash -mkdir -p data/slave1 -mkdir -p data/slave2 +configFile="slave.conf" +dataDir="data" + +if [[ -f $configFile ]]; then + read -r -p "A config file exists and will be overwritten, are you sure you want to contine? [y/N] " response + case $response in + [yY][eE][sS]|[yY]) + mv "${configFile}" "${configFile}_backup" + ;; + *) + exit 1 + ;; + esac +fi + + +mkdir -p $dataDir/slave1 +mkdir -p $dataDir/slave2 + +cat << EOF > $configFile +# address to bind ssh ports to +JENKINS_SLAVE_SSH_BIND=127.0.0.1 + +# slave 1 ssh port +JENKINS_SLAVE1_SSH_PORT=10001 + +# slave 2 ssh port +JENKINS_SLAVE2_SSH_PORT=10002 + +# ssh public key to connect from jenkins to this build slaves +JENKINS_SLAVE_SSH_PUBKEY= + +EOF +