Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae5628f370 | |||
| e8e2419537 | |||
| 4ee6027612 | |||
| 389e77e2ae | |||
| 7ce860db96 | |||
| 92f307d33d | |||
| 6e7d2d9f14 | |||
| c91dba475c | |||
| 04d988c584 | |||
| 27abc56a00 | |||
| 333b48ad60 | |||
| 4dee0bfb0a | |||
| 1e91825808 | |||
| c5cb1047ae | |||
| 18f9eed71d | |||
| 02de328bcd | |||
| 31f1a66fed | |||
| 5065145c6f |
69
.drone.yml
69
.drone.yml
@@ -17,7 +17,7 @@ volumes:
|
||||
|
||||
steps:
|
||||
# -----------------------------------------------------
|
||||
# 1. Fetch latest Git tag
|
||||
# 1. Fetch latest Tags
|
||||
# -----------------------------------------------------
|
||||
- name: fetch-tags
|
||||
image: docker:24
|
||||
@@ -28,34 +28,43 @@ steps:
|
||||
- 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: $LATEST_TAG"
|
||||
echo "Latest Git tag fetched: $LATEST_TAG"
|
||||
|
||||
# Save to file for downstream steps
|
||||
echo "$LATEST_TAG" > /drone/src/LATEST_TAG.txt
|
||||
if [ -z "$LATEST_TAG" ]; then
|
||||
echo "❌ No git tags found. Cannot continue."
|
||||
|
||||
# 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
|
||||
|
||||
# -----------------------------------------------------
|
||||
# 2. Check if remote image already exists
|
||||
# 2. Check existing Nakama Docker image
|
||||
# -----------------------------------------------------
|
||||
- name: check-remote-image
|
||||
image: docker:24
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
environment:
|
||||
REGISTRY_HOST:
|
||||
from_secret: REGISTRY_HOST
|
||||
commands:
|
||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
||||
- echo "Checking if $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG exists..."
|
||||
|
||||
- echo "Checking if lila-games/nakama-server:$IMAGE_TAG exists on remote Docker..."
|
||||
- echo "Existing Docker tags for lila-games/nakama-server:"
|
||||
- docker images --format "{{.Repository}}:{{.Tag}}" | grep "^lila-games/nakama-server" || echo "(none)"
|
||||
- |
|
||||
if docker pull $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG > /dev/null 2>&1; then
|
||||
echo "✅ Image already exists: $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG"
|
||||
if docker image inspect lila-games/nakama-server:$IMAGE_TAG > /dev/null 2>&1; then
|
||||
echo "✅ Docker image lila-games/nakama-server:$IMAGE_TAG already exists — skipping build"
|
||||
exit 78
|
||||
else
|
||||
echo "⚙️ Image does not exist. Will build."
|
||||
echo "⚙️ Docker image lila-games/nakama-server:$IMAGE_TAG not found — proceeding to build..."
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------
|
||||
@@ -68,28 +77,19 @@ steps:
|
||||
path: /var/run/docker.sock
|
||||
commands:
|
||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
||||
- echo "🔨 Building Nakama image lila-games/nakama-server:$IMAGE_TAG"
|
||||
# Enable buildx
|
||||
- docker buildx create --use
|
||||
|
||||
# Build for ARM64
|
||||
- echo "🔨 Building Nakama image lila-games/nakama-server:latest"
|
||||
- |
|
||||
docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
--network=host \
|
||||
-t lila-games/nakama-server:$IMAGE_TAG \
|
||||
-t lila-games/nakama-server:latest \
|
||||
--push \
|
||||
/drone/src
|
||||
docker build --network=host \
|
||||
-t lila-games/nakama-server:$IMAGE_TAG \
|
||||
-t lila-games/nakama-server:latest \
|
||||
/drone/src
|
||||
|
||||
# -----------------------------------------------------
|
||||
# 4. Push Nakama image to registry
|
||||
# 4. Push Nakama Image
|
||||
# -----------------------------------------------------
|
||||
- name: push-image
|
||||
image: docker:24
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
environment:
|
||||
REGISTRY_HOST:
|
||||
from_secret: REGISTRY_HOST
|
||||
@@ -97,15 +97,20 @@ steps:
|
||||
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..."
|
||||
|
||||
- echo "🔑 Logging into registry $REGISTRY_HOST ..."
|
||||
- echo "$REGISTRY_PASS" | docker login $REGISTRY_HOST -u "$REGISTRY_USER" --password-stdin
|
||||
- echo "🏷️ Tagging images..."
|
||||
- echo "🏷️ Tagging images with registry prefix..."
|
||||
- docker tag lila-games/nakama-server:$IMAGE_TAG $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG
|
||||
- docker tag lila-games/nakama-server:$IMAGE_TAG $REGISTRY_HOST/lila-games/nakama-server:latest
|
||||
- echo "📤 Pushing images..."
|
||||
- echo "📤 Pushing lila-games/nakama-server:$IMAGE_TAG ..."
|
||||
- docker push $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG
|
||||
- echo "📤 Pushing lila-games/nakama-server:latest ..."
|
||||
- docker push $REGISTRY_HOST/lila-games/nakama-server:latest
|
||||
|
||||
# -----------------------------------------------------
|
||||
@@ -148,9 +153,7 @@ steps:
|
||||
--add-host private-pi:192.168.1.111 \
|
||||
-e DB_ADDR="$DB_ADDR" \
|
||||
-e SERVER_KEY="$SERVER_KEY" \
|
||||
-v /mnt/omnissiah-vault/data/nakama/modules:/nakama/data/modules \
|
||||
-v /mnt/omnissiah-vault/data/nakama/storage:/nakama/data \
|
||||
$REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG
|
||||
lila-games/nakama-server:latest
|
||||
|
||||
# -----------------------------------------------------
|
||||
# Pipeline trigger
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -----------------------------------------------------
|
||||
# 1. Build the Nakama plugin
|
||||
# -----------------------------------------------------
|
||||
FROM golang:1.22 AS plugin_builder
|
||||
FROM --platform=linux/arm64 golang:1.21.6 AS plugin_builder
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
@@ -25,10 +25,11 @@ RUN mkdir -p build && \
|
||||
# -----------------------------------------------------
|
||||
# 2. Build final Nakama image
|
||||
# -----------------------------------------------------
|
||||
FROM heroiclabs/nakama:3.21.0 AS nakama
|
||||
FROM heroiclabs/nakama:3.21.0-arm
|
||||
|
||||
# Copy plugin from builder stage
|
||||
COPY --from=plugin_builder /workspace/build/main.so /nakama/data/modules/main.so
|
||||
#COPY --from=plugin_builder local.yml /nakama/data/config.yml
|
||||
|
||||
# Default Nakama startup (runs migrations + server)
|
||||
ENTRYPOINT exec /bin/sh -ecx "/nakama/nakama migrate up --database.address \"$DB_ADDR\" && exec /nakama/nakama --database.address \"$DB_ADDR\" --socket.server_key=\"$SERVER_KEY\" --http.cors=allow_origin:https://games.aetoskia.com"
|
||||
ENTRYPOINT exec /bin/sh -ecx "/nakama/nakama migrate up --database.address \"$DB_ADDR\" && exec /nakama/nakama --database.address \"$DB_ADDR\" --socket.server_key=\"$SERVER_KEY\""
|
||||
|
||||
Reference in New Issue
Block a user