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:
|
steps:
|
||||||
build-and-push:
|
build:
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: docker:24-dind
|
||||||
settings:
|
environment:
|
||||||
registry: hub.peikarband.ir
|
DOCKER_BUILDKIT: 1
|
||||||
repo: hub.peikarband.ir/peikarband/landing
|
commands:
|
||||||
username:
|
- echo "🔨 Building Docker image..."
|
||||||
from_secret: harbor_username
|
- docker buildx create --use --name builder || true
|
||||||
password:
|
- docker buildx build \
|
||||||
from_secret: harbor_password
|
--platform linux/amd64 \
|
||||||
tags:
|
--build-arg VERSION=${CI_COMMIT_SHA:0:8} \
|
||||||
- latest
|
--build-arg BUILD_DATE=${CI_PIPELINE_CREATED} \
|
||||||
- ${CI_COMMIT_SHA:0:8}
|
--build-arg PYTHON_VERSION=3.11 \
|
||||||
dockerfile: Dockerfile
|
--build-arg NODE_VERSION=20 \
|
||||||
context: .
|
--label org.opencontainers.image.created=${CI_PIPELINE_CREATED} \
|
||||||
platforms: linux/amd64
|
--label org.opencontainers.image.source=${CI_REPO_LINK} \
|
||||||
build_args:
|
--label org.opencontainers.image.url=${CI_REPO_LINK} \
|
||||||
- VERSION=${CI_COMMIT_SHA:0:8}
|
--label org.opencontainers.image.revision=${CI_COMMIT_SHA} \
|
||||||
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
--label org.opencontainers.image.version=${CI_COMMIT_SHA:0:8} \
|
||||||
- PYTHON_VERSION=3.11
|
--label org.opencontainers.image.title="Peikarband Landing" \
|
||||||
- NODE_VERSION=20
|
--label org.opencontainers.image.description="Peikarband hosting platform landing page" \
|
||||||
labels:
|
--tag hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8} \
|
||||||
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
--tag hub.peikarband.ir/peikarband/landing:latest \
|
||||||
- org.opencontainers.image.source=${CI_REPO_LINK}
|
--load \
|
||||||
- org.opencontainers.image.url=${CI_REPO_LINK}
|
--file Dockerfile \
|
||||||
- org.opencontainers.image.revision=${CI_COMMIT_SHA}
|
.
|
||||||
- org.opencontainers.image.version=${CI_COMMIT_SHA:0:8}
|
- echo "✅ Build completed"
|
||||||
- org.opencontainers.image.title=Peikarband Landing
|
volumes:
|
||||||
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
cache: inline
|
|
||||||
provenance: true
|
|
||||||
insecure: false
|
|
||||||
timeout: 30m
|
timeout: 30m
|
||||||
when:
|
when:
|
||||||
event: [push, tag, manual]
|
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