This commit is contained in:
79
.drone.yml
79
.drone.yml
@@ -16,51 +16,6 @@ volumes:
|
|||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: fetch-tags
|
|
||||||
image: docker:24
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache git
|
|
||||||
- git fetch --tags
|
|
||||||
- |
|
|
||||||
# Get latest Git tag and trim newline
|
|
||||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | tr -d '\n')
|
|
||||||
echo "Latest Git tag fetched: $LATEST_TAG"
|
|
||||||
|
|
||||||
# Save to file for downstream steps
|
|
||||||
echo "$LATEST_TAG" > /drone/src/LATEST_TAG.txt
|
|
||||||
|
|
||||||
# Read back for verification
|
|
||||||
IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
|
||||||
echo "Image tag read from file: $IMAGE_TAG"
|
|
||||||
|
|
||||||
# Validate
|
|
||||||
if [ -z "$IMAGE_TAG" ]; then
|
|
||||||
echo "❌ No git tags found! Cannot continue."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: check-remote-image
|
|
||||||
image: docker:24
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
commands:
|
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
|
||||||
|
|
||||||
- echo "Checking if lila-games/tic-tac-toe-ui:$IMAGE_TAG exists on remote Docker..."
|
|
||||||
- echo "Existing Docker tags for lila-games/tic-tac-toe-ui:"
|
|
||||||
- docker images --format "{{.Repository}}:{{.Tag}}" | grep "^lila-games/tic-tac-toe-ui" || echo "(none)"
|
|
||||||
- |
|
|
||||||
if docker image inspect lila-games/tic-tac-toe-ui:$IMAGE_TAG > /dev/null 2>&1; then
|
|
||||||
echo "✅ Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG already exists — skipping build"
|
|
||||||
exit 78
|
|
||||||
else
|
|
||||||
echo "⚙️ Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG not found — proceeding to build..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: build-image
|
- name: build-image
|
||||||
image: docker:24
|
image: docker:24
|
||||||
environment:
|
environment:
|
||||||
@@ -78,42 +33,16 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
||||||
|
|
||||||
- echo "🔨 Building Docker image lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
|
- echo "🔨 Building Docker image lila-games/tic-tac-toe-ui ..."
|
||||||
- |
|
- |
|
||||||
docker build --network=host \
|
docker build --network=host \
|
||||||
--build-arg VITE_WS_HOST="$WS_HOST" \
|
--build-arg VITE_WS_HOST="$WS_HOST" \
|
||||||
--build-arg VITE_WS_PORT="$WS_PORT" \
|
--build-arg VITE_WS_PORT="$WS_PORT" \
|
||||||
--build-arg VITE_WS_SKEY="$WS_SKEY" \
|
--build-arg VITE_WS_SKEY="$WS_SKEY" \
|
||||||
--build-arg VITE_WS_SSL="$WS_SSL" \
|
--build-arg VITE_WS_SSL="$WS_SSL" \
|
||||||
-t lila-games/tic-tac-toe-ui:$IMAGE_TAG \
|
|
||||||
-t lila-games/tic-tac-toe-ui:latest \
|
-t lila-games/tic-tac-toe-ui:latest \
|
||||||
/drone/src
|
/drone/src
|
||||||
|
|
||||||
- name: push-image
|
|
||||||
image: docker:24
|
|
||||||
environment:
|
|
||||||
REGISTRY_HOST:
|
|
||||||
from_secret: REGISTRY_HOST
|
|
||||||
REGISTRY_USER:
|
|
||||||
from_secret: REGISTRY_USER
|
|
||||||
REGISTRY_PASS:
|
|
||||||
from_secret: REGISTRY_PASS
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
commands:
|
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
|
||||||
|
|
||||||
- echo "🔑 Logging into registry $REGISTRY_HOST ..."
|
|
||||||
- echo "$REGISTRY_PASS" | docker login $REGISTRY_HOST -u "$REGISTRY_USER" --password-stdin
|
|
||||||
- echo "🏷️ Tagging images with registry prefix..."
|
|
||||||
- docker tag lila-games/tic-tac-toe-ui:$IMAGE_TAG $REGISTRY_HOST/lila-games/tic-tac-toe-ui:$IMAGE_TAG
|
|
||||||
- docker tag lila-games/tic-tac-toe-ui:$IMAGE_TAG $REGISTRY_HOST/lila-games/tic-tac-toe-ui:latest
|
|
||||||
- echo "📤 Pushing lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
|
|
||||||
- docker push $REGISTRY_HOST/lila-games/tic-tac-toe-ui:$IMAGE_TAG
|
|
||||||
- echo "📤 Pushing lila-games/tic-tac-toe-ui:latest ..."
|
|
||||||
- docker push $REGISTRY_HOST/lila-games/tic-tac-toe-ui:latest
|
|
||||||
|
|
||||||
- name: stop-old
|
- name: stop-old
|
||||||
image: docker:24
|
image: docker:24
|
||||||
volumes:
|
volumes:
|
||||||
@@ -131,16 +60,18 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
||||||
|
|
||||||
- echo "🚀 Starting container lila-games/tic-tac-toe-ui:$IMAGE_TAG ..."
|
- echo "🚀 Starting container lila-games/tic-tac-toe-ui ..."
|
||||||
- |
|
- |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name tic-tac-toe-ui \
|
--name tic-tac-toe-ui \
|
||||||
-p 3003:3000 \
|
-p 3003:3000 \
|
||||||
-e NODE_ENV=production \
|
-e NODE_ENV=production \
|
||||||
--restart always \
|
--restart always \
|
||||||
lila-games/tic-tac-toe-ui:$IMAGE_TAG
|
lila-games/tic-tac-toe-ui:latest
|
||||||
|
|
||||||
# Trigger rules
|
# Trigger rules
|
||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- push
|
||||||
|
- custom
|
||||||
|
|||||||
Reference in New Issue
Block a user