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

 

Android 프로젝트 CI/CD(Docker, Jenkins)[2] - Dockerfile 작성

Docker는 일종의 가상머신이다. VirtualBox, VMware와 같은 가상머신에서 OS를 가상화하여 사용하는 것처럼 Docker도 Container를 가상화하여 사용한다. 도커로 Jenkins를 사용하면 Docker Engine에서 호스트의..

bottom2top.tistory.com

 

300x250
728x90