This commit is contained in:
2022-02-23 11:05:30 +08:00
parent bb8a233a40
commit 4f841f8807
4 changed files with 75 additions and 1 deletions

61
.drone.yml Normal file
View File

@@ -0,0 +1,61 @@
kind: pipeline
type: docker
name: default
steps:
- name: build
image: golang:1.17.3-alpine3.15
commands:
- go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct
- go build -o server ./
- echo "go build success"
- name: docker build
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: hub.ncc.cx/fghwett/gh-proxy
registry: hub.ncc.cx
- name: scp docker-compose.yml
image: appleboy/drone-scp
settings:
host:
from_secret: ssh_host
port:
from_secret: ssh_port
username:
from_secret: ssh_username
password:
from_secret: ssh_password
target:
- /home/ubuntu/gh-proxy
source:
- docker-compose.yml
- name: docker deploy
image: appleboy/drone-ssh
settings:
host:
from_secret: ssh_host
port:
from_secret: ssh_port
username:
from_secret: ssh_username
password:
from_secret: ssh_password
script_stop: true
script:
- cd /opt/app/gh-proxy
- sudo mv -b /home/ubuntu/gh-proxy/docker-compose.yml .
- sudo docker-compose down
- sudo docker rmi hub.ncc.cx/fghwett/gh-proxy:latest
- sudo docker-compose up -d
- echo "deploy success"
trigger:
# branch:
# - master
event: # 事件触发器
include:
- push

5
Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM alpine:latest
WORKDIR /app
COPY ./server /app/server
EXPOSE 80
CMD ["/app/server"]

8
docker-compose.yml Normal file
View File

@@ -0,0 +1,8 @@
version: '3'
services:
notepad:
container_name: "gh-proxy"
restart: unless-stopped
ports:
- "9096:80"
image: hub.ncc.cx/fghwett/gh-proxy:latest

View File

@@ -128,7 +128,7 @@ func proxy(w http.ResponseWriter, r *http.Request, client *http.Client, pathname
func main() {
http.HandleFunc("/", fetchHandler)
err := http.ListenAndServe(fmt.Sprintf(":%d", 8091), nil)
err := http.ListenAndServe(fmt.Sprintf(":%d", 80), nil)
if err != nil {
fmt.Println("run server error: ", err)
return