-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1071 from uhafner/docker-refresh
Refactor Docker Jenkins installation
- Loading branch information
Showing
20 changed files
with
756 additions
and
321 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,70 @@ | ||
version: "3" | ||
name: codingstyle | ||
|
||
services: | ||
jenkins-controller: | ||
jenkins: | ||
container_name: jenkins | ||
build: | ||
context: docker/images/jenkins-controller | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
- ./docker/volumes/jenkins-home:/var/jenkins_home:cached | ||
- ./docker/volumes/jenkins-home:/var/jenkins_home # Mounts the local jenkins_home volume to the /var/jenkins_home path inside the container | ||
- agent-ssh-dir:/ssh-dir # Mounts the shared volume agent-ssh-dir to a path inside the container | ||
ports: | ||
- 8081:8080 # Jenkins UI - HOST:CONTAINER | ||
environment: | ||
- TRY_UPGRADE_IF_NO_MARKER=true | ||
- JAVA_OPTS= -Dstapler.jelly.noCache=true -Dhudson.remoting.ClassFilter=com.google.common.collect.ImmutableListMultimap -DexecutableWar.jetty.disableCustomSessionIdCookieName=true -DexecutableWar.jetty.sessionIdCookieName=warnings-ng-devenv | ||
- JAVA_OPTS= -Dstapler.jelly.noCache=true -Dhudson.remoting.ClassFilter=com.google.common.collect.ImmutableListMultimap -DexecutableWar.jetty.disableCustomSessionIdCookieName=true -DexecutableWar.jetty.sessionIdCookieName=codingstyle | ||
user: ${CURRENT_UID} | ||
restart: unless-stopped | ||
java11-agent: | ||
build: ./docker/images/java11-agent | ||
depends_on: | ||
- jenkins-controller | ||
key-generator: | ||
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service | ||
healthcheck: | ||
test: ["CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1"] | ||
# Checks if the conductor_ok file exists in the /ssh-dir path | ||
interval: 5s | ||
timeout: 10s | ||
retries: 5 | ||
|
||
key-generator: | ||
container_name: key-generator | ||
build: | ||
context: docker/images/key-generator | ||
stdin_open: true | ||
tty: true | ||
# The entrypoint script generates the SSH keys and outputs them to the /ssh-dir directory. | ||
entrypoint: sh -c "/usr/local/bin/keygen.sh /ssh-dir" # Runs the keygen.sh script and specifies the output directory | ||
volumes: | ||
- agent-ssh-dir:/ssh-dir # Mounts the agent-ssh-dir volume to the /ssh-dir path inside the container | ||
# The healthcheck command checks if the conductor_ok file exists in the /ssh-dir directory. | ||
healthcheck: | ||
test: ["CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1"] | ||
# Checks if the conductor_ok file exists in the /ssh-dir path | ||
interval: 5s | ||
timeout: 10s | ||
retries: 5 | ||
|
||
java-agent: | ||
container_name: java-agent | ||
build: docker/images/java-agent | ||
depends_on: | ||
key-generator: | ||
condition: service_completed_successfully # Depends on the successful completion of the sidekick_service | ||
jenkins: | ||
condition: service_started | ||
restart: unless-stopped | ||
healthcheck: | ||
test: ["CMD-SHELL", "[ -f /ssh-dir/conductor_ok ] || exit 1"] | ||
# Checks if the conductor_ok file exists in the /ssh-dir path | ||
interval: 5s | ||
timeout: 10s | ||
retries: 5 | ||
volumes: | ||
- agent-ssh-dir:/home/jenkins/.ssh:ro # Mounts the agent-ssh-dir volume to the /home/jenkins/.ssh path inside the container as read-only | ||
- ${HOME}/.m2/repository:/home/jenkins/.m2/repository # Mounts the local Maven repository to the /home/jenkins/.m2 path inside the container | ||
|
||
volumes: | ||
agent-ssh-dir: | ||
name: agent-ssh-dir # Creates a named volume called agent-ssh-dir | ||
jenkins_home: | ||
name: jenkins_home # Creates a named volume called jenkins_home | ||
external: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM jenkins/ssh-agent:latest-jdk21 | ||
|
||
# Install prerequisites for Java and Maven | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends ca-certificates curl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Maven | ||
ARG MAVEN_VERSION=3.9.8 | ||
|
||
SHELL ["/bin/bash", "-eo", "pipefail", "-c"] | ||
RUN curl -sS -L -O --output-dir /tmp/ --create-dirs https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ | ||
&& printf "%s" "$(sha512sum /tmp/apache-maven-${MAVEN_VERSION}-bin.tar.gz)" | sha512sum -c - \ | ||
&& curl -sS -L -O --output-dir /tmp/ --create-dirs https://downloads.apache.org/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz.sha512 \ | ||
&& printf "%s /tmp/apache-maven-${MAVEN_VERSION}-bin.tar.gz" "$(cat /tmp/apache-maven-${MAVEN_VERSION}-bin.tar.gz.sha512)" | sha512sum --check --status - \ | ||
&& tar xzf "/tmp/apache-maven-${MAVEN_VERSION}-bin.tar.gz" -C /opt/ \ | ||
&& rm "/tmp/apache-maven-${MAVEN_VERSION}-bin.tar.gz" \ | ||
&& ln -s /opt/apache-maven-${MAVEN_VERSION} /opt/maven \ | ||
&& ln -s /opt/maven/bin/mvn /usr/bin/mvn \ | ||
&& mkdir -p /etc/profile.d \ | ||
&& echo "export JAVA_HOME=$JAVA_HOME \n \ | ||
export M2_HOME=/opt/maven \n \ | ||
export PATH=${M2_HOME}/bin:${PATH}" > /etc/profile.d/maven.sh | ||
ENV M2_HOME="/opt/maven" | ||
ENV PATH="${M2_HOME}/bin/:${PATH}" | ||
RUN echo "PATH=${PATH}" >> /etc/environment && chown -R jenkins:jenkins "${JENKINS_AGENT_HOME}" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.