docker run --rm -m 400M -u root -p 9555:8080 -v jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v "$HOME":/home -d jenkinsci/blueocean
docker pull redis
docker run -itd -p 9557:6379 -m 500M -d --name=“redis” redis
//maven -> gradle, 使用gradle因为它配置镜像源比较方便
gradle init --type pom
容器启动失败?
docker inspect imagId
//其中有具体日志地址
cat
//查看内存
free -h
//之前遇到始终无法将当前机器加入主节点集群中
//后来发现是需要主节点界面进行配置
Jenkins部署过程中遇到的问题以及解决方案
1. 配置pipeline文件
//流水线配置
pipeline {
agent any
stages {
stage('检出') {
steps {
checkout([$class: 'GitSCM',
branches: [[name: GIT_BUILD_REF]],
userRemoteConfigs: [[
url: GIT_REPO_URL,
credentialsId: CREDENTIALS_ID
]]])
}
}
stage('编译') {
steps {
sh 'ifconfig'
sh 'chmod +x ./gradlew'
sh 'pwd'
sh './gradlew build --stacktrace'
}
}
stage('构建镜像') {
steps {
sh "docker build -t ${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} -f ${DOCKERFILE_PATH} ${DOCKER_BUILD_CONTEXT}"
}
}
stage('运行') {
steps {
sh "docker run -itd -p 9990:9990 -m 700M ${CODING_DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
}
}
}
environment {
CODING_DOCKER_REG_HOST = "${CCI_CURRENT_TEAM}-docker.pkg.${CCI_CURRENT_DOMAIN}"
CODING_DOCKER_IMAGE_NAME = "${PROJECT_NAME.toLowerCase()}/${DOCKER_REPO_NAME}/${DOCKER_IMAGE_NAME}"
}
}
2. 打包配置 gradle
//build.gradle,打包springboot应用成 fat jar
//运行
// chmod +x ./gradlew
//./gradlew build --stacktrace
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java'
id 'org.springframework.boot' version '2.5.5'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}
repositories {
// flatDir {dirs "libs"}
maven {
allowInsecureProtocol = true
url = uri('https://maven.aliyun.com/nexus/content/groups/public/')
}
maven {
allowInsecureProtocol = true
url = uri('https://repo.maven.apache.org/maven2/')
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE'
implementation 'com.alibaba:fastjson:1.2.73'
implementation 'org.springframework.boot:spring-boot-starter-security:2.1.5.RELEASE'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.0'
implementation 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.5'
implementation 'mysql:mysql-connector-java:8.0.16'
implementation 'org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE'
implementation 'org.springframework.boot:spring-boot-configuration-processor:2.1.5.RELEASE'
implementation 'io.swagger:swagger-annotations:1.5.20'
implementation 'org.springframework.boot:spring-boot-starter-mail:2.1.5.RELEASE'
implementation 'org.springframework.security:spring-security-jwt:1.0.11.RELEASE'
implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'com.pig4cloud.plugin:knife4j-spring-ui:3.0.2'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-redis
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-redis', version: '2.4.5'
testImplementation 'junit:junit:4.12'
testImplementation 'org.springframework.boot:spring-boot-devtools:2.1.5.RELEASE'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.5'
}
group = 'org.tagging'
version = 'v2.0.14'
description = 'tagging3'
java.sourceCompatibility = JavaVersion.VERSION_1_8
tasks.withType(JavaCompile) {
options.encoding = 'utf-8'
}
3.配置Dockerfile
// docker build -t tagging-system/docker-test/tagging-backend-dev:dev-0fff38c6347b23be3cafc0ae5b060b6ab591cac5 -f Dockerfile .
#FROM coding-public-docker.pkg.coding.net/public/docker/openjdk:8
#FROM python:3.7
# docker build -t tagging-system/docker-test/tagging-backend-dev:dev-5801d6c1286757a3106e37b991a48decf3589022 -f Dockerfile .
FROM java:8
#FROM qci
MAINTAINER Yuan Li
ADD ./build/libs/tagging3-v2.0.14.jar tagging3-v2.0.14.jar
ENTRYPOINT ["java","-jar","tagging3-v2.0.14.jar","--spring.profiles.active=pro"]
#CMD ["java", "-jar", "/root/workspace/tagging3-v2.0.14.jar", "--spring.profiles.active=${env}"]