k8s 製作映象並推送到映象倉庫
阿新 • • 發佈:2021-11-10
1.製作映象流程
2. 部署案例
2.1 匯入資料庫
-
建立資料庫和賬號密碼
mysql> create database if not exists java_demo default charset utf8 ; # 建立資料庫,預設utf8 Query OK, 1 row affected (0.00 sec) mysql> GRANT all on java_demo.* to 'java_demo'@'%' IDENTIFIED BY 'Aa@9953013'; #建立使用者並授權 Query OK, 0 rows affected, 1 warning (0.02 sec) mysql> flush privileges; #重新整理 Query OK, 0 rows affected (0.00 sec)
-
匯入資料
[root@localhost ~]# mysql -h127.0.0.1 -ujava_demo -p'Aa@9953013' < db/tables_ly_tomcat.sql mysql: [Warning] Using a password on the command line interface can be insecure.
-
修改連線資料庫檔案:src/main/resources/application.yml
server: port: 8080 spring: datasource: url: jdbc:mysql://192.168.0.230:3306/java_demo?characterEncoding=utf-8 username: java_demo password: Aa@9953013 driver-class-name: com.mysql.jdbc.Driver freemarker: allow-request-override: false cache: true check-template-location: true charset: UTF-8 content-type: text/html; charset=utf-8 expose-request-attributes: false expose-session-attributes: false expose-spring-macro-helpers: false suffix: .ftl template-loader-path: - classpath:/templates/
2.2 建立jenkins專案
2.2 進行專案編寫
- 點選配置
-
複製github原始碼地址
-
這裡是github地址,可以使用沒有密碼拉取
-
java打包:mvn clean package -Dmaven.test.skip=true
-
編寫dockerfile製作映象
cd $WORKSPACE && mv target/*.war target/ROOT.war cat > Dockerfile <<EOF FROM tomcat MAINTAINER [email protected] COPY target/ROOT.war /usr/local/tomcat/webapps/ROOT.war EOF docker build -t harbor.scajy.org/scajy/java:${tag} . docker login -uadmin -p'12345678' harbor.scajy.org docker push harbor.scajy.org/scajy/java:${tag}