From 16856a76a21cff700b9ac79139baee70130cf85b Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Mon, 31 May 2021 17:23:33 +0800 Subject: [PATCH] =?UTF-8?q?gitea=20+=20drone=20+=20drone=20runner=20+=20re?= =?UTF-8?q?gistry=20=E4=BD=9C=E4=B8=BA=20git=20=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E6=B5=8B=E8=AF=95=E3=80=81=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=92=8C=E6=89=93=E5=8C=85=E9=95=9C=E5=83=8F=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=88=B0=E7=A7=81=E6=9C=89=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 5fc019a057ae7a5ff4084610cc6c9314bbad4e30 Former-commit-id: c27ff117a67a3db831cac6d01fb4fc4b101256db --- labs/docker-lan/README.md | 15 ++++++++++++++- labs/docker-lan/conf/drone/Dockerfile | 1 - labs/docker-lan/conf/drone/app.go | 7 ------- .../conf/drone/{ => example}/.drone.yml | 11 +++++++---- labs/docker-lan/conf/drone/example/Dockerfile | 3 +++ labs/docker-lan/conf/drone/example/README.md | 2 ++ labs/docker-lan/conf/drone/example/app.go | 12 ++++++++++++ labs/docker-lan/conf/drone/{ => example}/go.mod | 0 labs/docker-lan/conf/drone/example/main_test.go | 16 ++++++++++++++++ labs/docker-lan/docker-compose.yml | 2 -- 10 files changed, 54 insertions(+), 15 deletions(-) delete mode 100644 labs/docker-lan/conf/drone/Dockerfile delete mode 100644 labs/docker-lan/conf/drone/app.go rename labs/docker-lan/conf/drone/{ => example}/.drone.yml (73%) create mode 100644 labs/docker-lan/conf/drone/example/Dockerfile create mode 100644 labs/docker-lan/conf/drone/example/README.md create mode 100644 labs/docker-lan/conf/drone/example/app.go rename labs/docker-lan/conf/drone/{ => example}/go.mod (100%) create mode 100644 labs/docker-lan/conf/drone/example/main_test.go diff --git a/labs/docker-lan/README.md b/labs/docker-lan/README.md index bc4d9a08..5f86a71d 100644 --- a/labs/docker-lan/README.md +++ b/labs/docker-lan/README.md @@ -1,4 +1,17 @@ -## +# gitea + drone + drone runner + registry 作为 git 服务器,自动测试、构建和打包镜像并发布到私有仓库 + + +## docker compose 配置网络后才能访问到宿主机 ip +``` +networks: + default: + name: mynetwork + driver: bridge + ipam: + config: + - subnet: 172.172.0.0/24 +``` + ## 修改docker配置使用镜像和私有http仓库 修改 /etc/docker/daemon.json 文件的 registry-mirrors 和 insecure-registries属性 ``` diff --git a/labs/docker-lan/conf/drone/Dockerfile b/labs/docker-lan/conf/drone/Dockerfile deleted file mode 100644 index c3c78df4..00000000 --- a/labs/docker-lan/conf/drone/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM alpine \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/app.go b/labs/docker-lan/conf/drone/app.go deleted file mode 100644 index ab12a00b..00000000 --- a/labs/docker-lan/conf/drone/app.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "fmt" - -func main(){ - fmt.Printf("Hello World!"); -} \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/.drone.yml b/labs/docker-lan/conf/drone/example/.drone.yml similarity index 73% rename from labs/docker-lan/conf/drone/.drone.yml rename to labs/docker-lan/conf/drone/example/.drone.yml index 4581881e..dd74a8b4 100644 --- a/labs/docker-lan/conf/drone/.drone.yml +++ b/labs/docker-lan/conf/drone/example/.drone.yml @@ -1,18 +1,21 @@ kind: pipeline name: default type: docker - steps: + - name: test + image: golang:1.12 + commands: + - go test + - ls - name: build image: golang:1.12 commands: - go build - - go test - + - ls - name: publish image: plugins/docker settings: registry: 172.20.32.1:5000 repo: 172.20.32.1:5000/go/hello-world insecure: true - tags: [ 1, 1.1, latest ] \ No newline at end of file + tags: [ 1, 1.2, latest ] \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/example/Dockerfile b/labs/docker-lan/conf/drone/example/Dockerfile new file mode 100644 index 00000000..890b64fb --- /dev/null +++ b/labs/docker-lan/conf/drone/example/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ADD example / +ENTRYPOINT ["/example"] \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/example/README.md b/labs/docker-lan/conf/drone/example/README.md new file mode 100644 index 00000000..fe1ef122 --- /dev/null +++ b/labs/docker-lan/conf/drone/example/README.md @@ -0,0 +1,2 @@ +# example + diff --git a/labs/docker-lan/conf/drone/example/app.go b/labs/docker-lan/conf/drone/example/app.go new file mode 100644 index 00000000..b12f3b4a --- /dev/null +++ b/labs/docker-lan/conf/drone/example/app.go @@ -0,0 +1,12 @@ +package main + +import "fmt" + +func main() { + fmt.Println(HelloWorld()) +} + +// HelloWorld is a function that returns a string containing "hello world". +func HelloWorld() string { + return "hello world" +} \ No newline at end of file diff --git a/labs/docker-lan/conf/drone/go.mod b/labs/docker-lan/conf/drone/example/go.mod similarity index 100% rename from labs/docker-lan/conf/drone/go.mod rename to labs/docker-lan/conf/drone/example/go.mod diff --git a/labs/docker-lan/conf/drone/example/main_test.go b/labs/docker-lan/conf/drone/example/main_test.go new file mode 100644 index 00000000..e9b0e558 --- /dev/null +++ b/labs/docker-lan/conf/drone/example/main_test.go @@ -0,0 +1,16 @@ +package main + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + os.Exit(m.Run()) +} + +func TestHelloWorld(t *testing.T) { + if HelloWorld() != "hello world" { + t.Errorf("got %s expected %s", HelloWorld(), "hello world") + } +} \ No newline at end of file diff --git a/labs/docker-lan/docker-compose.yml b/labs/docker-lan/docker-compose.yml index 6ca01ba9..ff3b2281 100644 --- a/labs/docker-lan/docker-compose.yml +++ b/labs/docker-lan/docker-compose.yml @@ -53,8 +53,6 @@ services: gitea: # init with ip:port https://docs.gitea.io/en-us/install-with-docker image: gitea/gitea:1.14.2 restart: always - networks: - - default environment: - USER_UID=1000 - USER_GID=1000