From 0bea4180a1d65d03a289cb6eb716e187a5efaafd Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:02:50 +0700 Subject: [PATCH 1/6] deploy --- .drone.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 5 +++++ docker-compose.yml | 12 +++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..cfc1b3d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,53 @@ +kind: pipeline +type: docker +name: default + +steps: + - name: build + image: golang + commands: + - go build -o cake_crm cmd/cake_crm/main.go + + - name: test + image: golang + commands: + - go test ./... + + - name: scp + image: appleboy/drone-scp + settings: + host: + from_secret: server_ip + username: + from_secret: ssh_user + key: + from_secret: ssh_key + port: + from_secret: ssh_port + target: + - deploys/cake_crm + source: + - cake_crm + - docker-compose.yml + - Dockerfile + rm: true + + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: server_ip + username: + from_secret: ssh_user + key: + from_secret: ssh_key + port: + from_secret: ssh_port + command_timeout: 10s + script: + - cd deploys/cake_crm + - docker-compose up -d --force-recreate + +trigger: + event: + - push diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fbd2a5b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM alpine:latest +RUN apk add --no-cache ca-certificates +COPY cake_crm /usr/local/bin/cake_crm +RUN chmod +x /usr/local/bin/cake_crm +CMD ["cake_crm"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9b23da0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + cake_crm: + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:8080" +# environment: +# - ENV_VAR_NAME=env_var_value + From 073d2b276110fb39b3123f1d7befffdf7f9d75b4 Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:08:19 +0700 Subject: [PATCH 2/6] test --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cfc1b3d..de1e9c4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: - name: test image: golang commands: - - go test ./... + - go test ./... - name: scp image: appleboy/drone-scp From 0387e78db82d297b2700cf28ffc4bc742352fb54 Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:16:32 +0700 Subject: [PATCH 3/6] test-2 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index de1e9c4..cfc1b3d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: - name: test image: golang commands: - - go test ./... + - go test ./... - name: scp image: appleboy/drone-scp From b9fdfb584bc339ecfc26e835b3f9aad7c1cfe31c Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:40:45 +0700 Subject: [PATCH 4/6] test-3 --- .drone.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index cfc1b3d..8fcfce2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,7 +6,7 @@ steps: - name: build image: golang commands: - - go build -o cake_crm cmd/cake_crm/main.go + - go build GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o cake_crm cmd/cake_crm/main.go - name: test image: golang diff --git a/Dockerfile b/Dockerfile index fbd2a5b..ba711ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,4 +2,4 @@ FROM alpine:latest RUN apk add --no-cache ca-certificates COPY cake_crm /usr/local/bin/cake_crm RUN chmod +x /usr/local/bin/cake_crm -CMD ["cake_crm"] +CMD ["/usr/local/bin/cake_crm"] \ No newline at end of file From 64eb0569ae98a6b74c63dbad6abb5805f6df7c3c Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:42:01 +0700 Subject: [PATCH 5/6] test-4 --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 8fcfce2..3290343 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,7 +6,7 @@ steps: - name: build image: golang commands: - - go build GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o cake_crm cmd/cake_crm/main.go + - go build -a -ldflags '-extldflags "-static"' -o cake_crm cmd/cake_crm/main.go GOOS=linux GOARCH=amd64 CGO_ENABLED=0 - name: test image: golang From 4f6af5cae97607894154faee4b9e6826568f6734 Mon Sep 17 00:00:00 2001 From: user-penguin Date: Sun, 19 May 2024 17:47:51 +0700 Subject: [PATCH 6/6] test-5 --- .drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 3290343..16501d3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,7 +6,10 @@ steps: - name: build image: golang commands: - - go build -a -ldflags '-extldflags "-static"' -o cake_crm cmd/cake_crm/main.go GOOS=linux GOARCH=amd64 CGO_ENABLED=0 + - set GOOS=linux + - set GOARCH=amd64 + - set CGO_ENABLED=0 + - go build -a -ldflags '-extldflags "-static"' -o cake_crm cmd/cake_crm/main.go - name: test image: golang