Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/gr26.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: gr26
run-name: Triggered by ${{ github.event_name }} to ${{ github.ref }} by @${{ github.actor }}

on:
push:
branches:
- "**"
tags:
- "**"

jobs:
build:
runs-on: ${{ matrix.runner }}
name: Build ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm

permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate platform pair
id: platform
run: |
platform=${{ matrix.platform }}
echo "pair=${platform//\//-}" >> $GITHUB_OUTPUT

- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: gr26
platforms: ${{ matrix.platform }}
outputs: type=image,name=ghcr.io/gaucho-racing/mapache/gr26,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ steps.platform.outputs.pair }}
cache-to: type=gha,scope=build-${{ steps.platform.outputs.pair }},mode=max

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.platform.outputs.pair }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
name: Merge manifests
needs: build

permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check if this commit has a release tag
id: release
run: |
tag=$(git tag --points-at HEAD | grep '^v' | head -n1)
if [ -n "$tag" ]; then
echo "Found tag: $tag"
if gh release view "$tag" --json tagName > /dev/null 2>&1; then
echo "release_tag=$tag" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
exit 0
fi
fi
echo "is_release=false" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate tag list
id: tags
shell: bash
run: |
TAGS="type=sha"

if [ "${GITHUB_REF_TYPE}" = "branch" ] && [ "${GITHUB_REF_NAME}" = "main" ]; then
TAGS="${TAGS}\ntype=raw,value=latest"
fi

if [ "${{ steps.release.outputs.is_release }}" = "true" ]; then
CLEAN_TAG=$(echo "${{ steps.release.outputs.release_tag }}" | sed 's/^v//')
TAGS="${TAGS}\ntype=raw,value=${CLEAN_TAG}"
fi

echo -e "tags<<EOF\n$TAGS\nEOF" >> $GITHUB_OUTPUT

- name: Extract image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/gaucho-racing/mapache/gr26
tags: ${{ steps.tags.outputs.tags }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/gaucho-racing/mapache/gr26@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/gaucho-racing/mapache/gr26:${{ steps.meta.outputs.version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

!example.env
*.env
tmp/

# === K8S ===
k8s/db-config.yaml
Expand Down
62 changes: 35 additions & 27 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,39 @@ services:
RINCON_PASSWORD: "admin"
RINCON_ENDPOINT: "http://rincon:10311"

# gr25:
# image: gauchoracing/mp_gr25:latest
# container_name: gr25
# restart: unless-stopped
# depends_on:
# - nanomq
# - rincon
# ports:
# - "7005:7005"
# environment:
# ENV: "DEV"
# PORT: "7005"
# SERVICE_ENDPOINT: "http://gr25:7005"
# SERVICE_HEALTH_CHECK: "http://gr25:7005/gr25/ping"
# MQTT_HOST: "nanomq"
# MQTT_PORT: "1883"
# MQTT_USER: "gr25"
# MQTT_PASSWORD: "gr25"
# DATABASE_HOST: ${DATABASE_HOST}
# DATABASE_PORT: ${DATABASE_PORT}
# DATABASE_NAME: ${DATABASE_NAME}
# DATABASE_USER: ${DATABASE_USER}
# DATABASE_PASSWORD: ${DATABASE_PASSWORD}
# RINCON_USER: "admin"
# RINCON_PASSWORD: "admin"
# RINCON_ENDPOINT: "http://rincon:10311"
gr26:
build:
context: .
dockerfile: gr26/Dockerfile.dev
container_name: gr26
restart: unless-stopped
depends_on:
- rincon
- nanomq
ports:
- "7005:7005"
volumes:
- ./gr26:/app/gr26
- ./mapache-go:/app/mapache-go
- gr26_go_cache:/go
environment:
ENV: "DEV"
PORT: "7005"
SERVICE_ENDPOINT: "http://gr26:7005"
SERVICE_HEALTH_CHECK: "http://gr26:7005/gr26/ping"
MQTT_HOST: "nanomq"
MQTT_PORT: "1883"
MQTT_USER: "gr26"
MQTT_PASSWORD: "gr26"
DATABASE_HOST: ${DATABASE_HOST}
DATABASE_PORT: ${DATABASE_PORT}
DATABASE_NAME: ${DATABASE_NAME}
DATABASE_USER: ${DATABASE_USER}
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
RINCON_USER: "admin"
RINCON_PASSWORD: "admin"
RINCON_ENDPOINT: "http://rincon:10311"
SKIP_AUTH_CHECK: "true"

# query:
# image: gauchoracing/mp_query:latest
Expand Down Expand Up @@ -172,4 +179,5 @@ services:
volumes:
pgdata:
auth_go_cache:
vehicle_go_cache:
vehicle_go_cache:
gr26_go_cache:
21 changes: 21 additions & 0 deletions gr26/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
root = "."
tmp_dir = "tmp"

[build]
bin = "./tmp/main"
cmd = "go mod tidy && go build -o ./tmp/main ."
delay = 1000
exclude_dir = ["tmp", "vendor"]
exclude_regex = ["_test.go"]
include_ext = ["go", "toml"]
kill_delay = "0s"
send_interrupt = false
poll = true
poll_interval = 500
stop_on_error = true

[log]
time = false

[misc]
clean_on_exit = true
Loading
Loading