Last active
November 13, 2022 19:58
-
-
Save angstyloop/1778eb51202eb23a44df7541f756402c to your computer and use it in GitHub Desktop.
Stand up an official Jenkins Docker container on Linux
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 | |
docker network create jenkins | |
docker run --name jenkins-docker --rm --detach --privileged --network jenkins --network-alias docker --env DOCKER_TLS_CERTDIR=/certs --volume jenkins-docker-certs:/certs/client --volume jenkins-data:/var/jenkins_home --publish 2376:2376 docker:dind --storage-driver overlay2 | |
mkdir -p ~/source/jenkins-docker/docker | |
cd ~/source/jenkins-docker | |
cat << EOF > docker/Dockerfile | |
FROM jenkins/jenkins:2.361.3-jdk11 | |
USER root | |
RUN apt-get update && apt-get install -y lsb-release | |
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \\ | |
https://download.docker.com/linux/debian/gpg | |
RUN echo "deb [arch=\$(dpkg --print-architecture) \\ | |
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \\ | |
https://download.docker.com/linux/debian \\ | |
\$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list | |
RUN apt-get update && apt-get install -y docker-ce-cli | |
USER jenkins | |
RUN jenkins-plugin-cli --plugins "blueocean:1.25.8 docker-workflow:521.v1a_a_dd2073b_2e" | |
EOF | |
docker build -t myjenkins-blueocean:2.361.3-1 -f docker/DockerFile docker/ | |
docker run --name jenkins-blueocean --restart=on-failure --detach --network jenkins --env DOCKER_HOST=tcp://docker:2376 --env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 --volume jenkins-data:/var/jenkins_home --volume jenkins-docker-certs:/certs/client:ro --publish 8080:8080 --publish 50000:50000 myjenkins-blueocean:2.361.3-1 | |
docker logs jenkins-blueocean | |
# look/grep for the admin password | |
# visit localhost:8080 | |
# REFERENCES | |
# [0] https://www.jenkins.io/doc/book/installing/docker/#setup-wizard | |
# [1] https://www.jenkins.io/doc/tutorials/build-a-node-js-and-react-app-with-npm/ |
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
pipeline { | |
agent { | |
docker { | |
image 'node:lts-bullseye-slim' | |
args '-p 3000:3000' | |
} | |
} | |
stages { | |
stage('Build') { | |
steps { | |
sh 'npm install' | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment