Update .drone.yml
updated drone yaml with correct way to use unix socks
This commit is contained in:
71
.drone.yml
71
.drone.yml
@@ -3,68 +3,81 @@ kind: pipeline
|
|||||||
type: docker
|
type: docker
|
||||||
name: default
|
name: default
|
||||||
|
|
||||||
# Platform specification for ARM64 runners
|
# ARM64 platform (for your Pi runner)
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
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:
|
steps:
|
||||||
# Step 1: Check if Docker image for current version already exists
|
# Step 1: Check if image for the latest tag exists locally
|
||||||
- name: check-version
|
- name: check-version
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
volumes:
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
- git fetch --tags
|
- git fetch --tags
|
||||||
- |
|
- |
|
||||||
# Get the latest Git tag
|
|
||||||
LATEST_TAG=$(git describe --tags --abbrev=0)
|
LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||||
echo "Latest Git tag: $LATEST_TAG"
|
echo "Latest Git tag: $LATEST_TAG"
|
||||||
|
|
||||||
# Check if Docker image exists
|
|
||||||
if docker image inspect apps/homepage:$LATEST_TAG > /dev/null 2>&1; then
|
if docker image inspect apps/homepage:$LATEST_TAG > /dev/null 2>&1; then
|
||||||
echo "Docker image apps/homepage:$LATEST_TAG already exists — skipping build"
|
echo "✅ Docker image apps/homepage:$LATEST_TAG already exists — skipping build"
|
||||||
exit 0
|
exit 78 # tells Drone to stop pipeline gracefully
|
||||||
else
|
else
|
||||||
echo "Docker image apps/homepage:$LATEST_TAG not found — building..."
|
echo "⚙️ Docker image apps/homepage:$LATEST_TAG not found — proceeding to build..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Step 2: Build Docker image with dynamic Git tag
|
# Step 2: Build Docker image (dynamic tag)
|
||||||
- name: build-image
|
- name: build-image
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
volumes:
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
commands:
|
commands:
|
||||||
- IMAGE_TAG=${DRONE_TAG:-latest}
|
- |
|
||||||
- echo "Building Docker image apps/homepage:$IMAGE_TAG ..."
|
IMAGE_TAG=${DRONE_TAG:-latest}
|
||||||
- docker build -t apps/homepage:$IMAGE_TAG .
|
echo "🔨 Building Docker image apps/homepage:$IMAGE_TAG ..."
|
||||||
|
docker build -t apps/homepage:$IMAGE_TAG .
|
||||||
|
|
||||||
# Step 3: Stop old container if exists
|
# Step 3: Stop old container (if exists)
|
||||||
- name: stop-old
|
- name: stop-old
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
volumes:
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
commands:
|
commands:
|
||||||
- IMAGE_TAG=${DRONE_TAG:-latest}
|
- |
|
||||||
- echo "Stopping old container..."
|
echo "🛑 Stopping old container..."
|
||||||
- docker rm -f homepage || true
|
docker rm -f homepage || true
|
||||||
|
|
||||||
# Step 4: Run container with dynamic tag
|
# Step 4: Run container
|
||||||
- name: run-container
|
- name: run-container
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
volumes:
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
- name: docker_sock
|
||||||
|
path: /var/run/docker.sock
|
||||||
commands:
|
commands:
|
||||||
- IMAGE_TAG=${DRONE_TAG:-latest}
|
- |
|
||||||
- echo "Starting container apps/homepage:$IMAGE_TAG ..."
|
IMAGE_TAG=${DRONE_TAG:-latest}
|
||||||
- docker run -d \
|
echo "🚀 Starting container apps/homepage:$IMAGE_TAG ..."
|
||||||
|
docker run -d \
|
||||||
--name homepage \
|
--name homepage \
|
||||||
-p 3001:3000 \
|
-p 3001:3000 \
|
||||||
-e NODE_ENV=production \
|
-e NODE_ENV=production \
|
||||||
apps/homepage:$IMAGE_TAG
|
apps/homepage:$IMAGE_TAG
|
||||||
|
|
||||||
# Trigger pipeline on Git tags
|
# Trigger rules
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
|
|||||||
Reference in New Issue
Block a user