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.

64 lines
1.6 KiB

1 month ago
kind: pipeline
1 month ago
type: docker
1 month ago
name: default
1 month ago
1 month ago
# --------------------------
# 共享配置(避免重复定义)
# --------------------------
volumes:
1 month ago
- name: shared-folder
1 month ago
host:
1 month ago
path: /root/app/drone/workspace
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
- pwd
1 month ago
- git clone http://47.112.165.44:3000/seekm/prdUploader.git
1 month ago
1 month ago
- name: build
1 month ago
image: golang:1.21-alpine
1 month ago
pull: never
1 month ago
environment:
GO111MODULE: on
1 month ago
CGO_ENABLED: 0
1 month ago
volumes:
1 month ago
- name: shared-folder
path: /workspace
1 month ago
commands:
- echo "Building binary..."
1 month ago
- pwd
1 month ago
- go build -o myapp -ldflags "-X main.RunMode=test -s -w" # 压缩符号表
- ls -lh myapp
1 month ago
# # --------------------------
# # [Deploy 阶段]
# # --------------------------
# - name: deploy
# image: docker:24.0-cli
# pull: never
# volumes:
# - name: docker-sock
# path: /var/run/docker.sock
# - name: go-build-cache # 复用之前的缓存卷(如有需要)
# path: /app
# environment:
# DOCKER_HOST: unix:///var/run/docker.sock # 显式指定 Docker 连接
# commands:
# - echo "Starting deployment..."
# - docker rm -f product_uploader || true
# - docker build -t prduploader:test-${DRONE_COMMIT_SHA:0:8} .
# - docker run -d \
# --name product_uploader \
# -p 11000:11000 \
# --restart on-failure \
# --memory 512m \
# prduploader:test-${DRONE_COMMIT_SHA:0:8}