You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.7 KiB

1 month ago
kind: pipeline
1 month ago
type: docker
1 month ago
name: default
1 month ago
1 month ago
volumes:
4 weeks ago
- name: docker-sock
host:
4 weeks ago
path: /var/run/docker.sock
1 month ago
- name: shared-folder
1 month ago
host:
1 month ago
path: /root/app/drone/workspace
1 month ago
- name: go-cache
host:
path: /root/app/drone/go-cache
1 month ago
1 month ago
clone:
disable: true
1 month ago
steps:
- name: clone
1 month ago
image: alpine/git:latest
1 month ago
pull: never
1 month ago
volumes:
1 month ago
- name: shared-folder
path: /workspace
1 month ago
commands:
1 month ago
- cd /workspace
4 weeks ago
- git clone http://47.112.165.44:3000/seekm/prdUploader.git
1 month ago
4 weeks ago
- name: build
image: golang:1.21-alpine
pull: never
environment:
GO111MODULE: on
CGO_ENABLED: 0
GOPROXY: https://goproxy.cn
GOMODCACHE: /go/pkg/mod
volumes:
- name: shared-folder
path: /workspace
- name: go-cache
path: /go/pkg/mod
commands:
- echo "Building binary..."
- cd /workspace/prdUploader
- pwd
- echo $GOMODCACHE
- go mod tidy
- go build -o myapp -ldflags "-X main.RunMode=test -s -w"
- echo "Building binary finished"
- ls -lh myapp
4 weeks ago
- name: deploy
image: docker:24.0-cli
pull: never
volumes:
- name: shared-folder
path: /workspace
- name: docker-sock
path: /var/run/docker.sock
commands:
4 weeks ago
- echo "Building Docker image..."
- cd /workspace/prdUploader
- docker build -t prduploader:latest .
- echo "Running Docker container..."
4 weeks ago
- |
if docker run -p 11000:11000 prduploader:latest; then
echo "Deployment successful, cleaning up old container and image..."
else
echo "Deployment failed, keeping old container and image."
fi
4 weeks ago
- cd ..
4 weeks ago
- rm -rf prdUploader
- echo "Deployment finished"