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