refactor: جدا کردن build و push در Woodpecker CI
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
CD - Build & Deploy / build-and-push (push) Has been cancelled
CD - Build & Deploy / package-helm (push) Has been cancelled
CD - Build & Deploy / deploy-staging (push) Has been cancelled
CD - Build & Deploy / deploy-production (push) Has been cancelled
CD - Build & Deploy / release (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / security (push) Has been cancelled
- جدا کردن build و push به دو step مجزا - استفاده از docker:24-dind برای کنترل بیشتر - build step: فقط build میکند با --load - push step: فقط push میکند - مزایا: امکان retry فقط push، debug بهتر
This commit is contained in:
@@ -1,35 +1,51 @@
|
||||
steps:
|
||||
build-and-push:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: hub.peikarband.ir
|
||||
repo: hub.peikarband.ir/peikarband/landing
|
||||
username:
|
||||
from_secret: harbor_username
|
||||
password:
|
||||
from_secret: harbor_password
|
||||
tags:
|
||||
- latest
|
||||
- ${CI_COMMIT_SHA:0:8}
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
build_args:
|
||||
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||
- PYTHON_VERSION=3.11
|
||||
- NODE_VERSION=20
|
||||
labels:
|
||||
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
||||
- org.opencontainers.image.source=${CI_REPO_LINK}
|
||||
- org.opencontainers.image.url=${CI_REPO_LINK}
|
||||
- org.opencontainers.image.revision=${CI_COMMIT_SHA}
|
||||
- org.opencontainers.image.version=${CI_COMMIT_SHA:0:8}
|
||||
- org.opencontainers.image.title=Peikarband Landing
|
||||
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
||||
cache: inline
|
||||
provenance: true
|
||||
insecure: false
|
||||
build:
|
||||
image: docker:24-dind
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
commands:
|
||||
- echo "🔨 Building Docker image..."
|
||||
- docker buildx create --use --name builder || true
|
||||
- docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg VERSION=${CI_COMMIT_SHA:0:8} \
|
||||
--build-arg BUILD_DATE=${CI_PIPELINE_CREATED} \
|
||||
--build-arg PYTHON_VERSION=3.11 \
|
||||
--build-arg NODE_VERSION=20 \
|
||||
--label org.opencontainers.image.created=${CI_PIPELINE_CREATED} \
|
||||
--label org.opencontainers.image.source=${CI_REPO_LINK} \
|
||||
--label org.opencontainers.image.url=${CI_REPO_LINK} \
|
||||
--label org.opencontainers.image.revision=${CI_COMMIT_SHA} \
|
||||
--label org.opencontainers.image.version=${CI_COMMIT_SHA:0:8} \
|
||||
--label org.opencontainers.image.title="Peikarband Landing" \
|
||||
--label org.opencontainers.image.description="Peikarband hosting platform landing page" \
|
||||
--tag hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8} \
|
||||
--tag hub.peikarband.ir/peikarband/landing:latest \
|
||||
--load \
|
||||
--file Dockerfile \
|
||||
.
|
||||
- echo "✅ Build completed"
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
timeout: 30m
|
||||
when:
|
||||
event: [push, tag, manual]
|
||||
|
||||
push:
|
||||
image: docker:24-dind
|
||||
environment:
|
||||
DOCKER_BUILDKIT: 1
|
||||
commands:
|
||||
- echo "📤 Pushing Docker image..."
|
||||
- echo $${HARBOR_PASSWORD} | docker login hub.peikarband.ir -u $${HARBOR_USERNAME} --password-stdin
|
||||
- docker push hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}
|
||||
- docker push hub.peikarband.ir/peikarband/landing:latest
|
||||
- echo "✅ Push completed"
|
||||
secrets:
|
||||
- HARBOR_USERNAME
|
||||
- HARBOR_PASSWORD
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
timeout: 10m
|
||||
when:
|
||||
event: [push, tag, manual]
|
||||
|
||||
Reference in New Issue
Block a user