Dockerfile customized in work
The intranet is used by the company, so the installation packages used in some dockerfiles can be easily transferred to the intranet under the external network. The installation packages are placed in the corresponding Dockerfile directory of the same level.
java:8.0
FROM redhat:7.5 MAINTAINER XXX ARG JAVA_VERSION=8u241 #The rpm package of the jdk and the Dockerfile are placed in the same directory COPY jdk-${JAVA_VERSION}-linux-x64.rpm /opt/ RUN rpm -ivh /opt/jdk-${JAVA_VERSION}-linux-x64.rpm \ && rm /opt/jdk-${JAVA_VERSION}-linux-x64.rpm
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -f Dockerfile -t rhel_7.5/java:8.0 .
jenkins-slave:8.0
FROM rhel_7.5/java:8.0 MAINTAINER XXX ARG GIT_VERSION=2.11.0 ARG user=jenkins ARG group=jenkins ARG uid=1000 ARG gid=1000 ARG JENKINS_AGENT_HOME=/home/${user} ENV JENKINS_AGENT_HOME=${JENKINS_AGENT_HOME} \ SONAR_SCANNER_VERSION=2.8 \ PATH=/opt/sonar-scanner/bin:$PATH #I need to use sonar scanner and git here. I don't need to write anything COPY sonar-scanner-$SONAR_SCANNER_VERSION.zip /opt/ RUN groupadd -g ${gid} ${group} \ && useradd -d "${JENKINS_AGENT_HOME}" -u "${uid}" -g "${gid}" -m -s /bin/bash "${user}" RUN sed -i /etc/ssh/sshd_config \ -e 's/#PermitRootLogin.*/PermitRootLogin yes/' \ -e 's/PasswordAuthentication.*/PasswordAuthentication no/' \ -e 's/SyslogFacility.*/SyslogFacility AUTH/' \ -e 's/#LogLevel.*/LogLevel INFO/' \ && mkdir /var/run/sshd \ && /usr/sbin/sshd-keygen -A \ && /usr/sbin/sshd #I'm redhat here, so I'll install it in the following way. If it's Ubuntu, you can adjust it by yourself RUN /bin/bash -c ' yum -y install git; \ yum install -y unzip; \ yum clean all' RUN cd /opt \ && unzip sonar-scanner-$SONAR_SCANNER_VERSION.zip \ && mv sonar-scanner-$SONAR_SCANNER_VERSION sonar-scanner \ && rm sonar-scanner-$SONAR_SCANNER_VERSION.zip VOLUME "${JENKINS_AGENT_HOME}" "/tmp" "/run" "/var/run" WORKDIR "${JENKINS_AGENT_HOME}" EXPOSE 22
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -f Dockerfile -t jenkins-slave:8.0 .
nodejs:v10.15.0
FROM jenkins-slave:8.0 MAINTAINER XXX #npm private server is not necessary. It's ok if it's not matched. You can also set npm as follows ENV NODE_VERSION=v10.15.0 \ NPM_REGISTRY_URL=http://npm.xxx.com #install nodejs RUN xz -d /opt/node-${NODE_VERSION}-linux-x64.tar.xz \ && cd /opt/ \ && tar -xvf node-${NODE_VERSION}-linux-x64.tar \ && rm node-${NODE_VERSION}-linux-x64.tar \ && mv node-{NODE_VERSION}-linux-x64 node \ && ln -s /opt/node/bin/node /usr/local/bin/node \ && ln -s /opt/node/bin/npm /usr/local/bin/npm \ && npm config set registry ${NPM_REGISTRY_URL} ENV NODE_HOME=/opt/node \ PATH=$PATH:$NODE_HOME/bin \ NODE_PATH=$NODE_HOME/lib/node_modules
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -t nodejs:v10.15.0 .
maven:8.0
FROM jenkins-slave:8.0 MAINTAINER XXX ENV M2_HOME=/opt/maven \ M2_VERSION=3.6.0 \ PATH=/opt/maven/bin:$PATH COPY apache-maven-${M2_VERSION}-bin.tar.gz /opt/ RUN cd /opt \ && tar -xvf /opt/apache-maven-${M2_VERSION}-bin.tar.gz -C /opt/ \ && mv apache-maven-${M2_VERSION} maven \ && rm /opt/apache-maven-${M2_VERSION}-bin.tar.gz #I need to overwrite my own settings file and use the configured maven private server COPY conf/settings.xml ${M2_HOME}/conf/settings.xml
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -t maven:8.0 .
httpd:7.5
FROM redhat:7.5 MAINTAINER XXX #I failed to install Yum directly here, so I reconfigured a Yum source and set it up without yum COPY BOC.repo /etc/yum.repos.d/BOC.repo RUN /bin/bash -c ' yum -y install httpd; \ yum clean all' EXPOSE 80 CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -t httpd:7.5 .
newman:5.0.0
FROM nodejs:v10.15.0 MAINTAINER XXX ENV NEWMAN_HOME=/opt/node ENV PATH=$PATH:$NEWMAN_HOME/bin RUN npm install -g newman \ && npm install -g newman-reporter-html
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -t newman:5.0.0 .
sonar:6.7.4
FROM java:8.0 MAINTAINER XXX ENV SONAR_VERSION=6.7.4 \ SONARQUBE_HOME=/opt/sonarqube \ # Database configuration # Defaults to using H2 SONARQUBE_JDBC_USERNAME=sonar \ SONARQUBE_JDBC_PASSWORD=sonar \ SONARQUBE_JDBC_URL="jdbc:mysql://IP:PORT/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false" # Http port EXPOSE 9000 RUN groupadd -r sonarqube && useradd -r -g sonarqube sonarqube COPY sonarqube-$SONAR_VERSION.zip /opt/ COPY run.sh /opt/ RUN /bin/bash -c ' yum install -y unzip; \ yum clean all' RUN set -x \ && cd /opt \ && unzip sonarqube-$SONAR_VERSION.zip \ && mv sonarqube-$SONAR_VERSION sonarqube \ && rm sonarqube-$SONAR_VERSION.zip \ && mv run.sh $SONARQUBE_HOME/bin/ \ && chmod +x $SONARQUBE_HOME/bin/run.sh ENTRYPOINT /opt/sonarqube/bin/run.sh RUN cd /opt \ && chown -R sonarqube:sonarqube sonarqube
Run.sh (in the same directory as Dockerfile)
#!/bin/bash set -e if [ "${1:0:1}" != '-' ]; then exec "$@" fi chown -R sonarqube:sonarqube $SONARQUBE_HOME exec sudo -u sonarqube \ java -jar /opt/sonarqube/lib/sonar-application-$SONAR_VERSION.jar \ -Dsonar.log.console=true \ -Dsonar.jdbc.username="$SONARQUBE_JDBC_USERNAME" \ -Dsonar.jdbc.password="$SONARQUBE_JDBC_PASSWORD" \ -Dsonar.jdbc.url="$SONARQUBE_JDBC_URL" \ -Dsonar.web.javaAdditionalOpts="$SONARQUBE_WEB_JVM_OPTS -Djava.security.egd=file:/dev/./urandom" \ "$@"
Switch to the directory where the Dockerfile is located and execute the following command to make the image:
# docker build -t sonar:6.7.4 .