diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 6c317d0..0000000 --- a/.drone.yml +++ /dev/null @@ -1,141 +0,0 @@ -kind: pipeline -type: docker -name: build-multiarch-docker - -# 匹配 Runner 标签 -node: - runtime: docker - arch: amd64 - multiarch: true - -# 触发条件 -trigger: - include: - - event: push - branch: [main, release/*] - - event: tag - -volumes: - - name: docker-sock - host: - path: /var/run/docker.sock - -clone: - disable: true - depth: 1 - tags: true - -steps: - - name: diagnose - image: docker:29.0-cli - volumes: - - name: docker-sock - path: /var/run/docker.sock - commands: - - apk add --no-cache curl jq 2>/dev/null || true - - echo "=== Docker CLI ==="; docker version - - echo "=== Docker Engine API ==="; curl -s --unix-socket /var/run/docker.sock http://localhost/version | jq -r '.ApiVersion' - - - name: debug engine api - image: curlimages/curl - volumes: - - name: docker-sock - path: /var/run/docker.sock - commands: - - curl --unix-socket /var/run/docker.sock http://localhost/version - - - name: debug docker version - image: docker:29.0-cli - environment: - DOCKER_API_VERSION: "1.45" - DOCKER_HOST: unix:///var/run/docker.sock - volumes: - - name: docker-sock - path: /var/run/docker.sock - commands: - - which docker - - docker --version - - docker version - - # 登录容器仓库(使用 docker login) - - name: registry login - image: docker:29.0-cli # 使用官方 Docker CLI 镜像 - volumes: - - name: docker-sock - path: /var/run/docker.sock - environment: - REGISTRY_SERVER: "swr.cn-north-4.myhuaweicloud.com" - REGISTRY_USER: - from_secret: secrets/data/swr_username - REGISTRY_PASSWORD: - from_secret: secrets/swr_password - commands: - - | - echo "Logging into registry..." - echo "=== Debug Variables ===" - echo "REGISTRY_SERVER: $REGISTRY_SERVER" - echo "REGISTRY_USER: ${REGISTRY_USER:-empty}" - echo "REGISTRY_PASSWORD: ${REGISTRY_PASSWORD:-empty}" - echo "========================" - echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY_SERVER" -u "$REGISTRY_USER" --password-stdin || { - echo "Registry login failed!" - exit 1 - } - - # 构建并推送镜像(使用 docker build/push) - - name: build and push - image: docker:29.0-cli - volumes: - - name: docker-sock - path: /var/run/docker.sock - environment: - REGISTRY_REPO: "swr.cn-north-4.myhuaweicloud.com/colovu/scratch" - DRONE_TAG: ${DRONE_TAG} - DRONE_COMMIT_SHA: ${DRONE_COMMIT_SHA} - DRONE_BRANCH: ${DRONE_BRANCH} - commands: - - | - set -euo pipefail - - if [ -n "${DRONE_TAG:-}" ]; then - IMAGE_TAG="$DRONE_TAG" - else - IMAGE_TAG="${DRONE_COMMIT_SHA:0:8:-unknown}" - fi - - echo "=== Debug Variables ===" - echo "DRONE_TAG: ${DRONE_TAG:-empty}" - echo "DRONE_COMMIT_SHA: ${DRONE_COMMIT_SHA:-empty}" - echo "DRONE_BRANCH: ${DRONE_BRANCH:-empty}" - echo "REGISTRY_REPO: ${REGISTRY_REPO:-empty}" - echo "IMAGE_TAG: $IMAGE_TAG" - echo "========================" - - echo "Building image..." - docker build -t "${REGISTRY_REPO}:${IMAGE_TAG}" . - - echo "Pushing image..." - docker push "${REGISTRY_REPO}:${IMAGE_TAG}" - - # 可选:打 latest 标签(仅 main 分支) - if [ "${DRONE_BRANCH}" = "main" ]; then - docker tag "${REGISTRY_REPO}:${IMAGE_TAG}" "${REGISTRY_REPO}:latest" - docker push "${REGISTRY_REPO}:latest" - fi - - echo "Image pushed: ${REGISTRY_REPO}:${IMAGE_TAG}" - - # 清理步骤 - - name: cleanup - image: docker:29.0-cli - volumes: - - name: docker-sock - path: /var/run/docker.sock - commands: - - | - echo "Logging out of registry..." - docker logout swr.cn-north-4.myhuaweicloud.com || true - echo "Cleaning up unused images..." - docker system prune -af || true - when: - status: [success, failure] diff --git a/hello-world/hello-world b/hello-world/hello-world new file mode 100755 index 0000000..987fdb6 Binary files /dev/null and b/hello-world/hello-world differ diff --git a/hello-world/main.go b/hello-world/main.go new file mode 100644 index 0000000..7f0730c --- /dev/null +++ b/hello-world/main.go @@ -0,0 +1,6 @@ +package main +import "fmt" + +func main() { + fmt.Println("Hello from scratch!") +}