|
|
@ -54,7 +54,7 @@ Runner是在Workflow被触发时运行它们的服务器。每个Runner一次可 |
|
|
|
|
|
|
|
#### 1.复制项目代码 |
|
|
|
|
|
|
|
将 https://github.com/OpenEduTech/DaseDevOps/tree/master 复制到自己的账户下后,会生成DaseDevops仓库。注意:下面所有图中显示的devops_demp仓库其实对应的是DaseDevops仓库下的dasedevops_spring_demo项目。 |
|
|
|
将 https://github.com/OpenEduTech/DaseDevOps/tree/master 复制到自己的账户下后,会生成DaseDevops仓库。注意:下面所有图中显示的devops_demo仓库其实对应的是DaseDevops仓库下的dasedevops_spring_demo项目。 |
|
|
|
|
|
|
|
![image-20231111152635356](./images/openedu_repo.png) |
|
|
|
|
|
|
@ -89,7 +89,9 @@ ssh-keygen -t rsa -C "102155014xx@stu.ecnu.edu.cn" |
|
|
|
|
|
|
|
首先,创建一个 centOS 云主机,1 核 2G 配置,20M 带宽流量计费,数据盘设置为 50 G |
|
|
|
|
|
|
|
安装Docker,安装docker-compose。 |
|
|
|
安装Docker(参照https://gitea.shuishan.net.cn/xslu_dase_ecnu_edu_cn/cloud-computing-course/src/branch/master/Assignment2.md), |
|
|
|
|
|
|
|
安装docker-compose。 |
|
|
|
|
|
|
|
##### docker-compose 安装过程: |
|
|
|
|
|
|
@ -156,7 +158,7 @@ vi /etc/profile |
|
|
|
在文件末尾添加 |
|
|
|
|
|
|
|
``` |
|
|
|
export JAVA_HOME=/usr/java/jdk-1.8.0_391 |
|
|
|
export JAVA_HOME=/usr/java/jdk1.8.0_391 |
|
|
|
export PATH=$JAVA_HOME/bin:$PATH |
|
|
|
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib |
|
|
|
``` |
|
|
@ -185,7 +187,7 @@ source /etc/profile |
|
|
|
tar -xvf apache-maven-3.9.5-bin.tar.gz |
|
|
|
``` |
|
|
|
|
|
|
|
执行 `vim /etc/profile` 配置环境变量 |
|
|
|
执行 `vi /etc/profile` 配置环境变量 |
|
|
|
|
|
|
|
``` |
|
|
|
MAVEN_HOME=/usr/local/apache-maven-3.9.5 |
|
|
@ -259,7 +261,7 @@ sudo vi conf/settings.xml |
|
|
|
|
|
|
|
![image-20231112155904281](./images/personal_page.png) |
|
|
|
|
|
|
|
需要把 默认仓库类型 设置为公开。 |
|
|
|
### **需要把 默认仓库类型 设置为公开。** |
|
|
|
|
|
|
|
## `作业 1: 创建完成以后,进入个人实例-命名空间页面,截图插入实验报告。` |
|
|
|
|
|
|
@ -296,6 +298,7 @@ jobs: |
|
|
|
run: | |
|
|
|
whoami |
|
|
|
pwd |
|
|
|
cd dasedevops_spring_demo |
|
|
|
mvn -B package --file pom.xml |
|
|
|
pwd |
|
|
|
- name: Login to Aliyun Container Registry (ACR) |
|
|
@ -323,7 +326,7 @@ jobs: |
|
|
|
- name: Copy single file to remote |
|
|
|
uses: garygrossgarten/github-action-scp@release |
|
|
|
with: |
|
|
|
local: ./docker-compose.yml |
|
|
|
local: ./dasedevops_spring_demo/docker-compose.yml |
|
|
|
remote: scp/devops_demo/docker-compose.yml |
|
|
|
host: ${{ secrets.HOST }} |
|
|
|
username: ${{ secrets.USER_NAME }} |
|
|
@ -401,9 +404,10 @@ env: |
|
|
|
编辑 DockerFile 也是为了分别将这六个 module 打包成镜像,上传到镜像仓库中。这么看,这个 yml 文件是不是也不那么复杂?🐶 |
|
|
|
|
|
|
|
gateway微服务的Dockerfile文件内容如下: |
|
|
|
**在六个文件夹下分别创建名为dockerfile的文件** |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /gateway.jar |
|
|
@ -414,7 +418,7 @@ EXPOSE 8080 |
|
|
|
hello微服务的Dockerfile文件内容如下: |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /hello.jar |
|
|
@ -425,7 +429,7 @@ EXPOSE 8001 |
|
|
|
login微服务的Dockerfile文件内容如下: |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /login.jar |
|
|
@ -436,7 +440,7 @@ EXPOSE 8000 |
|
|
|
provider_one微服务的Dockerfile文件内容如下: |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /provider_one.jar |
|
|
@ -447,7 +451,7 @@ EXPOSE 8666 |
|
|
|
provider_two微服务的Dockerfile文件内容如下: |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /provider_two.jar |
|
|
@ -458,7 +462,7 @@ EXPOSE 8667 |
|
|
|
provider_three微服务的Dockerfile文件内容如下: |
|
|
|
|
|
|
|
```dockerfile |
|
|
|
FROM java:8 |
|
|
|
FROM openjdk:8 |
|
|
|
MAINTAINER ningzhicheng |
|
|
|
VOLUME /tmp |
|
|
|
ADD ./target/*.jar /provider_three.jar |
|
|
@ -505,6 +509,9 @@ services: |
|
|
|
- "8668:8668" |
|
|
|
``` |
|
|
|
|
|
|
|
文件目录如下: |
|
|
|
![image](./images/schema.png) |
|
|
|
|
|
|
|
随后将所有文件提交到暂存区,创建提交信息,推送提交。 |
|
|
|
|
|
|
|
``` |
|
|
|