Last active
September 14, 2020 00:01
-
-
Save bryantrobbins/c8a990af680e74d14cf3 to your computer and use it in GitHub Desktop.
Docker jenkins and nexus example
This file contains 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
#/bin/bash | |
archive=$1 | |
if [ -z "$archive" ]; then | |
echo "No archive provided." | |
echo "Usage: $0 archive.tar" | |
exit | |
fi | |
if [ -e "$archive" ]; then | |
echo "File $archive already exists. Please choose another name" | |
exit | |
fi | |
local=`pwd` | |
echo "Backing up to $archive" | |
echo "Exporting data current rdata container" | |
docker rm backup | |
docker run --name backup --volumes-from rdata -v $local:/backup busybox tar cvf /backup/$archive var/jenkins_home nexus | |
docker rm backup |
This file contains 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
FROM ubuntu:12.04 | |
MAINTAINER Bryan Robbins <[email protected]> | |
# Get latest packages | |
RUN apt-get update && apt-get clean | |
# Needed for Jenkins | |
RUN apt-get install --no-install-recommends openjdk-7-jdk -y | |
# Needed for Jenkins jobs | |
RUN apt-get install ant wget unzip bzip2 xvfb -y | |
# Install Gradle | |
RUN wget https://services.gradle.org/distributions/gradle-2.1-bin.zip | |
RUN unzip gradle-2.1-bin.zip | |
RUN mv gradle-2.1 gradle | |
ENV PATH $PATH:/gradle/bin | |
RUN mkdir jslave | |
RUN mkdir jslave/home | |
ADD swarm.jar /jslave/swarm.jar | |
EXPOSE 22 | |
EXPOSE 5005 | |
WORKDIR jslave | |
CMD ["java", "-jar", "swarm.jar", "-master", "http://jenkins:8080", "-username", "admin", "-password", "somethingsomething", "-labels", "basic", "-executors", "1", "-fsroot", "/jslave/home"] |
This file contains 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
#/bin/bash | |
archive=$1 | |
if [ -z "$archive" ]; then | |
echo "No archive provided." | |
echo "Usage: $0 archive.tar" | |
exit | |
fi | |
echo "Loading from $archive" | |
# Clean up any old stuff here | |
docker rm rdata | |
# Start new data container | |
echo "Starting new rdata container" | |
docker run -d --name rdata -v /var/jenkins_home -v /nexus busybox true | |
# Copy in files from old data container | |
echo "Restoring old files into new rdata" | |
docker rm restore | |
docker run --name restore --volumes-from rdata -v $(pwd):/backup busybox tar xvf /backup/$archive | |
docker rm restore |
This file contains 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
#/bin/bash | |
now=`date +%s` | |
arch="backup.$now.tar" | |
./backup.sh $arch | |
./load.sh $arch | |
rm $arch | |
./start.sh |
This file contains 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
#/bin/bash | |
archive=$1 | |
if [ -z "$archive" ]; then | |
echo "No archive provided." | |
echo "Usage: $0 archive.tar" | |
exit | |
fi | |
echo "Restoring from $archive" | |
./load.sh $archive | |
./start.sh |
This file contains 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
#/bin/bash | |
# Start nexus | |
docker stop nexus | |
docker rm nexus | |
docker run -d --name nexus --volumes-from rdata -p 8081:8081 conceptnotfound/sonatype-nexus | |
# Start jenkins | |
docker stop jenkins | |
docker rm jenkins | |
docker run -d --name jenkins --volumes-from rdata --link nexus:nexus -p 8080:8080 -u root jenkins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment