Files
homepage/.drone.yml
aetos 871b497ffa
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone Build was killed
Update .drone.yml
updated drone yaml with correct way to use unix socks
2025-10-06 17:00:49 +00:00

86 lines
2.1 KiB
YAML

---
kind: pipeline
type: docker
name: default
# ARM64 platform (for your Pi runner)
platform:
os: linux
arch: arm64
# Mount host Docker socket so steps can use Docker CLI
volumes:
- name: docker_sock
host:
path: /var/run/docker.sock
workspace:
path: /drone/src
steps:
# Step 1: Check if image for the latest tag exists locally
- name: check-version
image: docker:24
volumes:
- name: docker_sock
path: /var/run/docker.sock
commands:
- apk add --no-cache git
- git fetch --tags
- |
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "Latest Git tag: $LATEST_TAG"
if docker image inspect apps/homepage:$LATEST_TAG > /dev/null 2>&1; then
echo "✅ Docker image apps/homepage:$LATEST_TAG already exists — skipping build"
exit 78 # tells Drone to stop pipeline gracefully
else
echo "⚙️ Docker image apps/homepage:$LATEST_TAG not found — proceeding to build..."
fi
# Step 2: Build Docker image (dynamic tag)
- name: build-image
image: docker:24
volumes:
- name: docker_sock
path: /var/run/docker.sock
commands:
- |
IMAGE_TAG=${DRONE_TAG:-latest}
echo "🔨 Building Docker image apps/homepage:$IMAGE_TAG ..."
docker build -t apps/homepage:$IMAGE_TAG .
# Step 3: Stop old container (if exists)
- name: stop-old
image: docker:24
volumes:
- name: docker_sock
path: /var/run/docker.sock
commands:
- |
echo "🛑 Stopping old container..."
docker rm -f homepage || true
# Step 4: Run container
- name: run-container
image: docker:24
volumes:
- name: docker_sock
path: /var/run/docker.sock
commands:
- |
IMAGE_TAG=${DRONE_TAG:-latest}
echo "🚀 Starting container apps/homepage:$IMAGE_TAG ..."
docker run -d \
--name homepage \
-p 3001:3000 \
-e NODE_ENV=production \
apps/homepage:$IMAGE_TAG
# Trigger rules
trigger:
event:
- push
- tag
- custom