Dockerfile制作jenkins

下载jenkins

# wget -O jenkins-2.391.war https://mirrors.tuna.tsinghua.edu.cn/jenkins/war/2.391/jenkins.war

run_jenkins.sh

#!/bin/bash

#java -server -Xms1024m -Xmx1024m -Xss512k -jar jenkins-2.391.war --webroot=/apps/jenkins/jenkins-data --pluginroot=/apps/jenkins/plugins  --httpPort=8080
java -server -Xms1024m -Xmx1024m -Xss512k -jar jenkins-2.391.war

Dockerfile

FROM uhub.service.ucloud.cn/wgs-test/jdk:17.0.5

ENV JENKINS_HOME=/apps/jenkins/jenkins_home
ADD jenkins-2.391.war /apps/jenkins/
ADD run_jenkins.sh /usr/bin/
RUN apt-get update \ 
    && apt-get -y install libfreetype-dev tzdata \
    && rm -rf /var/lib/apt/lists/* \
    && ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "LC_TIME=en_DK.UTF-8" >>  /etc/default/locale 

WORKDIR /apps/jenkins
EXPOSE 8080 

CMD ["/usr/bin/run_jenkins.sh"]

build-jenkins_image.sh

#!/bin/bash

docker build -t  uhub.service.ucloud.cn/wgs-test/jenkins:v2.391 .

构建jenkins镜像

# ./build-jenkins_image.sh 
Sending build context to Docker daemon  98.31MB
Step 1/8 : FROM uhub.service.ucloud.cn/wgs-test/jdk:17.0.5
 ---> 142801e4f730
Step 2/8 : ENV JENKINS_HOME=/apps/jenkins/jenkins_home
 ---> Running in 6316615cf934
Removing intermediate container 6316615cf934
 ---> a56745097577
Step 3/8 : ADD jenkins-2.391.war /apps/jenkins/
 ---> c2135a8774fc
Step 4/8 : ADD run_jenkins.sh /usr/bin/
 ---> f19978b543e4
Step 5/8 : RUN apt-get update     && apt-get -y install libfreetype-dev tzdata     && rm -rf /var/lib/apt/lists/*     && ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime     && echo "LC_TIME=en_DK.UTF-8" >>  /etc/default/locale
 ---> Running in 3c92a5ecc9a9
 ...
 Step 6/8 : WORKDIR /apps/jenkins
 ---> Running in d328e6f51a41
Removing intermediate container d328e6f51a41
 ---> 70cddffe044d
Step 7/8 : EXPOSE 8080
 ---> Running in e979edd2f15b
Removing intermediate container e979edd2f15b
 ---> 12091b2bbf35
Step 8/8 : CMD ["/usr/bin/run_jenkins.sh"]
 ---> Running in daf25caf7aaf
Removing intermediate container daf25caf7aaf
 ---> cc73d1eb46be
Successfully built cc73d1eb46be
Successfully tagged uhub.service.ucloud.cn/wgs-test/jenkins:v2.391

运行jenkins

# docker run --rm -p 9080:8080 --name jenkins-2 -v /data/apps/jenkins:/apps/jenkins/jenkins_home  uhub.service.ucloud.cn/wgs-test/jenkins:v2.391
Running from: /apps/jenkins/jenkins-2.391.war
webroot: /apps/jenkins/jenkins_home/war
2023-02-21 08:02:23.867+0000 [id=1]	INFO	winstone.Logger#logInternal: Beginning extraction from war file
2023-02-21 08:02:24.684+0000 [id=1]	WARNING	o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2023-02-21 08:02:24.726+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: jetty-10.0.13; built: 2022-12-07T20:13:20.134Z; git: 1c2636ea05c0ca8de1ffd6ca7f3a98ac084c766d; jvm 17.0.5+9-LTS-191
2023-02-21 08:02:24.968+0000 [id=1]	INFO	o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2023-02-21 08:02:25.009+0000 [id=1]	INFO	o.e.j.s.s.DefaultSessionIdManager#doStart: Session workerName=node0
2023-02-21 08:02:25.382+0000 [id=1]	INFO	hudson.WebAppMain#contextInitialized: Jenkins home directory: /apps/jenkins/jenkins_home found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2023-02-21 08:02:25.470+0000 [id=1]	INFO	o.e.j.s.handler.ContextHandler#doStart: Started w.@3f29e26{Jenkins v2.391,/,file:///apps/jenkins/jenkins_home/war/,AVAILABLE}{/apps/jenkins/jenkins_home/war}
2023-02-21 08:02:25.478+0000 [id=1]	INFO	o.e.j.server.AbstractConnector#doStart: Started ServerConnector@3eb81efb{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2023-02-21 08:02:25.486+0000 [id=1]	INFO	org.eclipse.jetty.server.Server#doStart: Started Server@7d286fb6{STARTING}[10.0.13,sto=0] @2194ms
2023-02-21 08:02:25.487+0000 [id=27]	INFO	winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2023-02-21 08:02:25.718+0000 [id=34]	INFO	jenkins.InitReactorRunner$1#onAttained: Started initialization
2023-02-21 08:02:25.736+0000 [id=41]	INFO	jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2023-02-21 08:02:26.275+0000 [id=32]	INFO	jenkins.InitReactorRunner$1#onAttained: Prepared all plugins
2023-02-21 08:02:26.278+0000 [id=42]	INFO	jenkins.InitReactorRunner$1#onAttained: Started all plugins
2023-02-21 08:02:26.283+0000 [id=32]	INFO	jenkins.InitReactorRunner$1#onAttained: Augmented all extensions
2023-02-21 08:02:26.522+0000 [id=33]	INFO	jenkins.InitReactorRunner$1#onAttained: System config loaded
2023-02-21 08:02:26.523+0000 [id=37]	INFO	jenkins.InitReactorRunner$1#onAttained: System config adapted
2023-02-21 08:02:26.523+0000 [id=44]	INFO	jenkins.InitReactorRunner$1#onAttained: Loaded all jobs
2023-02-21 08:02:26.525+0000 [id=33]	INFO	jenkins.InitReactorRunner$1#onAttained: Configuration for all jobs updated
2023-02-21 08:02:26.539+0000 [id=60]	INFO	hudson.util.Retrier#start: Attempt #1 to do the action check updates server
2023-02-21 08:02:26.947+0000 [id=37]	INFO	jenkins.install.SetupWizard#init: 

*************************************************************
*************************************************************
*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

dd7ec48d67f648c98b0b6f30cde1604b

This may also be found at: /apps/jenkins/jenkins_home/secrets/initialAdminPassword

*************************************************************
*************************************************************
*************************************************************

2023-02-21 08:02:48.127+0000 [id=40]	INFO	jenkins.InitReactorRunner$1#onAttained: Completed initialization
2023-02-21 08:02:48.187+0000 [id=26]	INFO	hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
2023-02-21 08:02:49.383+0000 [id=60]	INFO	h.m.DownloadService$Downloadable#load: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
2023-02-21 08:02:49.383+0000 [id=60]	INFO	hudson.util.Retrier#start: Performed the action check updates server successfully at the attempt #1

访问jenkins

查看jenkins数据目录

# docker exec -ti jenkins-2 ls -l /apps/jenkins/jenkins_home
total 52
-rw-r--r--  1 root root 1658 Feb 21 15:52 config.xml
-rw-r--r--  1 root root  156 Feb 21 15:51 hudson.model.UpdateCenter.xml
-rw-r--r--  1 root root  171 Feb 21 15:51 jenkins.telemetry.Correlator.xml
drwxr-xr-x  2 root root 4096 Feb 21 15:51 jobs
-rw-r--r--  1 root root  907 Feb 21 15:51 nodeMonitors.xml
drwxr-xr-x  2 root root 4096 Feb 21 15:51 nodes
drwxr-xr-x  2 root root 4096 Feb 21 15:51 plugins
-rw-r--r--  1 root root   64 Feb 21 15:51 secret.key
-rw-r--r--  1 root root    0 Feb 21 15:51 secret.key.not-so-secret
drwx------  2 root root 4096 Feb 21 15:51 secrets
drwxr-xr-x  2 root root 4096 Feb 21 15:52 updates
drwxr-xr-x  2 root root 4096 Feb 21 15:51 userContent
drwxr-xr-x  3 root root 4096 Feb 21 15:51 users
drwxr-xr-x 11 root root 4096 Feb 21 15:51 war

jenkins 参数

Usage: java -jar jenkins.war [--option=value] [--option=value]

Options:
   --webroot                = folder where the WAR file is expanded into. Default is ${JENKINS_HOME}/war
   --pluginroot             = folder where the plugin archives are expanded into. Default is ${JENKINS_HOME}/plugins
                              (NOTE: this option does not change the directory where the plugin archives are stored)
   --extractedFilesFolder   = folder where extracted files are to be located. Default is the temp folder
   --enable-future-java     = allows running with Java versions which are not fully supported
   --paramsFromStdIn        = Read parameters from standard input (stdin)
   --version                = Print version to standard output (stdout) and exit
   --javaHome               = Override the JAVA_HOME variable
   --config                 = load configuration properties from here. Default is ./winstone.properties
   --prefix                 = add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none
   --commonLibFolder        = folder for additional jar files. Default is ./lib

   --extraLibFolder         = folder for additional jar files to add to Jetty classloader

   --logfile                = redirect log messages to this file
   --logThrowingLineNo      = show the line no that logged the message (slow). Default is false
   --logThrowingThread      = show the thread that logged the message. Default is false
   --debug                  = set the level of Winstone debug msgs (1-9). Default is 5 (INFO level)

   --httpPort               = set the http listening port. -1 to disable, Default is 8080
   --httpListenAddress      = set the http listening address. Default is all interfaces
   --httpKeepAliveTimeout   = how long idle HTTP keep-alive connections are kept around (in ms; default 30000)?
   --httpsPort              = set the https listening port. -1 to disable, Default is disabled
   --httpsListenAddress     = set the https listening address. Default is all interfaces
   --httpsKeepAliveTimeout  = how long idle HTTPS keep-alive connections are kept around (in ms; default 30000)?
   --httpsKeyStore          = the location of the SSL KeyStore file. Default is ./winstone.ks
   --httpsKeyStorePassword  = the password for the SSL KeyStore file. Default is null
   --httpsKeyManagerType    = the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509
   --httpsRedirectHttp      = redirect http requests to https (requires both --httpPort and --httpsPort)
   --http2Port              = set the http2 listening port. -1 to disable, Default is disabled
   --httpsSniHostCheck      = if the SNI Host name must match when there is an SNI certificate. Check disabled per default
   --httpsSniRequired       = if a SNI certificate is required. Disabled per default
   --http2ListenAddress     = set the http2 listening address. Default is all interfaces
   --excludeCipherSuites    = set the ciphers to exclude (comma separated, use blank quote " " to exclude none) (default is
                           // Exclude weak / insecure ciphers 
                           "^.*_(MD5|SHA|SHA1)$", 
                           // Exclude ciphers that don't support forward secrecy 
                           "^TLS_RSA_.*$", 
                           // The following exclusions are present to cleanup known bad cipher 
                           // suites that may be accidentally included via include patterns. 
                           // The default enabled cipher list in Java will not include these 
                           // (but they are available in the supported list). 
                           "^SSL_.*$", 
                           "^.*_NULL_.*$", 
                           "^.*_anon_.*$" 
   --controlPort            = set the shutdown/control port. -1 to disable, Default disabled

   --sessionTimeout         = set the http session timeout value in minutes. Default to what webapp specifies, and then to 60 minutes
   --sessionEviction        = set the session eviction timeout for idle sessions in seconds. Default value is 180. -1 never evict, 0 evict on exit
   --mimeTypes=ARG          = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:...
                              (e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile)
   --requestHeaderSize=N    = set the maximum size in bytes of the request header. Default is 8192.
   --responseHeaderSize=N    = set the maximum size in bytes of the response header. Default is 8192.
   --maxParamCount=N        = set the max number of parameters allowed in a form submission to protect
                              against hash DoS attack (oCERT #2011-003). Default is 10000.
   --useJmx                 = Enable Jetty Jmx
   --qtpMaxThreadsCount     = max threads number when using Jetty Queued Thread Pool
   --jettyAcceptorsCount    = Jetty Acceptors number
   --jettySelectorsCount    = Jetty Selectors number
   --usage / --help         = show this message
 Security options:
   --realmClassName               = Set the realm class to use for user authentication. Defaults to ArgumentsRealm class

   --argumentsRealm.passwd.<user> = Password for user <user>. Only valid for the ArgumentsRealm realm class
   --argumentsRealm.roles.<user>  = Roles for user <user> (comma separated). Only valid for the ArgumentsRealm realm class

   --fileRealm.configFile         = File containing users/passwds/roles. Only valid for the FileRealm realm class

 Access logging:
   --accessLoggerClassName        = Set the access logger class to use for user authentication. Defaults to disabled
   --simpleAccessLogger.format    = The log format to use. Supports combined/common/resin/custom (SimpleAccessLogger only)
   --simpleAccessLogger.file      = The location pattern for the log file(SimpleAccessLogger only)

 

posted @ 2023-01-11 19:08  小吉猫  阅读(476)  评论(0编辑  收藏  举报