jekin docker gitee
docker 安装 jenkins
docker run -d --restart=always \
--name jenkins -uroot -p 10340:8080 \
-p 10341:50000 \
-v /home/docker/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker jenkins/jenkins:lts
登录 ip:10340
全局配置 自动下载maven
新建任务
配置仓库地址跟用户名密码
新增 maven 跟shell指令
shell指令
APP_NAME=enterprise-server
APP_PORT=8686
RUN_ENV=prod
cd /var/jenkins_home/workspace/$APP_NAME
docker stop $APP_NAME || true
docker rm $APP_NAME || true
docker rmi $APP_NAME || true
docker build -f ruoyi-admin/Dockerfile1 -t $APP_NAME .
docker run --net host --privileged=true -d -p $APP_PORT:$APP_PORT -v /docker/server1/ftp/:/ruoyi/server/ftp/ -v /docker/server1/logs/:/ruoyi/server/logs/ -e "SPRING_PROFILES_ACTIVE=$RUN_ENV" --name $APP_NAME $APP_NAME:latest
安装插件
Publish over SSH
locate
配置dockerfile 文件
#FROM findepi/graalvm:java17-native
FROM openjdk:17.0.2-oraclelinux8MAINTAINER Lion LiRUN mkdir -p /docker/ruoyi/server/logs \/docker/ruoyi/server/ftp \/docker/ruoyi/server/temp \/docker/ruoyi/skywalking/agentWORKDIR /docker/ruoyi/serverENV SERVER_PORT=8080 LANG=C.UTF-8 LC_ALL=C.UTF-8 JAVA_OPTS=""EXPOSE ${SERVER_PORT}ADD ruoyi-admin/target/ruoyi-admin.jar ./app.jarENTRYPOINT java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${SERVER_PORT} \# 应用名称 如果想区分集群节点监控 改成不同的名称即可#-Dskywalking.agent.service_name=ruoyi-server \#-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar \-jar app.jar \-XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC ${JAVA_OPTS}
参考资料 jdk安装
jenkins
jekin docker gitee
前置条件
- 安装jdk
- 安装git
- 安装maven
- docker 启动该jenkins
安装jdk17
- 下载
cd /usr/local
wget https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_linux-aarch64_bin.tar.gzwget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
- 解压jdk
mkdir /usr/local/jdk
tar -zxvf openjdk-17.0.1_linux-aarch64_bin.tar.gz -C /usr/local/jdk
- 配置环境变量
vim /etc/profile
4 .添加配置
export JAVA_HOME=/usr/local/jdk/jdk-17.0.1
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
- 刷新配置
source /etc/profile
docker安装jenkins
拉取镜像
docker pull jenkins/jenkins:2.344 #拉取jenkins镜像
启动kenkins
docker run -d -p 10240:8080 -p 10241:50000 \
-v /var/jenkins_mount:/var/jenkins_home -u 0 \
-v /usr/local/maven/apache-maven-3.8.5:/usr/local/maven \
-v /usr/local/git/bin/git:/usr/local/git \
-v /etc/localtime:/etc/localtime --name myjenkin 镜像id
docker 安装
docker run -d --restart=always \
--name jenkins -uroot -p 10340:8080 \
-p 10341:50000 \
-v /home/docker/jenkins:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker jenkins/jenkins:lts
#!/bin/bash -il
docker rm -f app_docker
sleep 1
docker rmi -f app_docker:1.0
sleep 1
mvn clean install -Dmaven.test.skip=true
sleep 1
docker build -t app_docker:1.0 -f ./src/main/docker/Dockerfile .
sleep 1
docker run -d -p 8000:8000 --name app_docker app_docker:1.0
#!/bin/bash -il
docker rm -f enterprise-server1
sleep 1
docker rmi -f ruoyi/ruoyi-server:5.1.2
sleep 1
mvn clean install -Dmaven.test.skip=true
sleep 1
docker build -t ruoyi/ruoyi-server:5.1.2 -f /docker/dokckerfile/Dockerfile .
sleep 1
docker run -d -p 8000:8000 --name enterprise-server1 ruoyi/ruoyi-server:5.1.2