add deploy

This commit is contained in:
Владимир Фёдоров 2024-05-19 19:04:02 +07:00
parent f5255f6721
commit 887caf5d79
5 changed files with 76 additions and 1 deletions

56
.drone.yml Normal file
View File

@ -0,0 +1,56 @@
kind: pipeline
type: docker
name: default
steps:
- name: build
image: golang
commands:
- set GOOS=linux
- set GOARCH=amd64
- set CGO_ENABLED=0
- go build -a -ldflags '-extldflags "-static"' -o ${REPO_NAME} cmd/${REPO_NAME}/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/${REPO_NAME}
source:
- ${REPO_NAME}
- 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/${REPO_NAME}
- docker-compose up -d --force-recreate
trigger:
event:
- push

View File

@ -7,3 +7,6 @@ internal/**
README.md
go.mod
.drone.yml
docker-compose.yml
Dockerfile

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM alpine:latest
RUN apk add --no-cache ca-certificates
COPY ${REPO_NAME} /usr/local/bin/${REPO_NAME}
RUN chmod +x /usr/local/bin/${REPO_NAME}
CMD ["/usr/local/bin/${REPO_NAME}"]

View File

@ -1,6 +1,6 @@
# template
Шалон для Go сервисов
Шалон для Go сервисов (имя репо должно быть snake case)
Init

11
docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
version: '3.8'
services:
${REPO_NAME}:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
# environment:
# - ENV_VAR_NAME=env_var_value