320x100
320x100
FROM alpine
# JENKINS environment variable setting
ARG http_port=8080
ARG agent_port=50000
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
ENV JENKINS_HOME /var/jenkins_home
ENV JENKINS_SLAVE_AGENT_PORT ${agent_port}
ARG REF=/usr/share/jenkins/ref
ENV REF $REF
# make directory for JENKINS
RUN mkdir -p $JENKINS_HOME \
&& chown ${uid}:${gid} $JENKINS_HOME \
&& groupadd -g ${gid} ${group} \
&& useradd -d /var/jenkins_home -u ${uid} -g ${gid} -m -s /bin/bash ${user}
# make volume for share to localhost
VOLUME $JENKINS_HOME
# Add Tini (process optimize on container)
# gpg = encryption tool
ENV TINI_VERSION v0.19.0
COPY tini_pub.gpg ${JENKINS_HOME}/tini_pub.gpg
RUN curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print-architecture) -o /sbin/tini \
&& curl -fsSL https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$(dpkg --print-architecture).asc -o /sbin/tini.asc \
&& gpg --no-tty --import ${JENKINS_HOME}/tini_pub.gpg \
&& gpg --verify /sbin/tini.asc \
&& rm -rf /sbin/tini.asc /root/.gnupg \
&& chmod +x /sbin/tini
# Jenkins version define and enroll environment
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.303.3}
# SHA-256 code for jenkins install (it depoends on jenkins version)
ARG JENKINS_SHA=~~~
# Jenkins download url define
ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkins-war/${JENKINS_VERSION}/jenkins-war-${JENKINS_VERSION}.war
# Jenkins download and install
RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && \
echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha256sum -c -
ENV JENKINS_UC https://updates.jenkins.io
ENV JENKINS_UC_EXPERIMENTAL=https://updates.jenkins.io/experimental
ENV JENKINS_INCREMENTALS_REPO_MIRROR=https://repo.jenkins-ci.org/incrementals
RUN chown -R ${user} /var/jenkins_home "$REF"
# web port open
EXPOSE ${http_port}
# slave agent port for docker engine
EXPOSE ${agent_port}
ENV COPY_REFERENCE_FILE_LOG $JENKINS_HOME/copy_reference_file.log
USER ${user}
COPY jenkins-support /usr/local/bin/jenkins-support
COPY jenkins.sh /usr/local/bin/jenkins.sh
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/jenkins.sh"]
# from a derived Dockerfile, can use `RUN plugins.sh active.txt` to setup ${REF}/plugins from a support bundle
COPY plugins.sh /usr/local/bin/plugins.sh
COPY install-plugins.sh /usr/local/bin/install-plugins.sh
Refference
300x250
728x90
'CICD > Jenkins' 카테고리의 다른 글
Jenkins와 Slack 연동 (0) | 2021.11.28 |
---|---|
JENKINS_HOME is almost full 해결법 (0) | 2021.11.22 |
Jenkins에 pull request 이벤트 트리거 설정 (0) | 2021.11.17 |
Docker와 Jenkins를 이용한 nodejs 서버 CI/CD 구축 (0) | 2021.10.21 |
Docker와 Jenkins를 이용한 CI/CD 구축 (0) | 2021.10.15 |