Skip to content

Commit 8d3cf7b

Browse files
authored
Merge pull request #117 from Gaucho-Racing/bk1031/gr26
feat: gr26 ingest service
2 parents 8465c9d + 0f24cdc commit 8d3cf7b

29 files changed

Lines changed: 1878 additions & 40 deletions

.github/workflows/gr26.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: gr26
2+
run-name: Triggered by ${{ github.event_name }} to ${{ github.ref }} by @${{ github.actor }}
3+
4+
on:
5+
push:
6+
branches:
7+
- "**"
8+
tags:
9+
- "**"
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.runner }}
14+
name: Build ${{ matrix.platform }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- platform: linux/amd64
20+
runner: ubuntu-24.04
21+
- platform: linux/arm64
22+
runner: ubuntu-24.04-arm
23+
24+
permissions:
25+
contents: read
26+
packages: write
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Log in to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Generate platform pair
43+
id: platform
44+
run: |
45+
platform=${{ matrix.platform }}
46+
echo "pair=${platform//\//-}" >> $GITHUB_OUTPUT
47+
48+
- name: Build and push by digest
49+
id: build
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: gr26
53+
platforms: ${{ matrix.platform }}
54+
outputs: type=image,name=ghcr.io/gaucho-racing/mapache/gr26,push-by-digest=true,name-canonical=true,push=true
55+
cache-from: type=gha,scope=build-${{ steps.platform.outputs.pair }}
56+
cache-to: type=gha,scope=build-${{ steps.platform.outputs.pair }},mode=max
57+
58+
- name: Export digest
59+
run: |
60+
mkdir -p /tmp/digests
61+
digest="${{ steps.build.outputs.digest }}"
62+
touch "/tmp/digests/${digest#sha256:}"
63+
64+
- name: Upload digest
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: digests-${{ steps.platform.outputs.pair }}
68+
path: /tmp/digests/*
69+
if-no-files-found: error
70+
retention-days: 1
71+
72+
merge:
73+
runs-on: ubuntu-latest
74+
name: Merge manifests
75+
needs: build
76+
77+
permissions:
78+
contents: read
79+
packages: write
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
with:
85+
fetch-depth: 0
86+
fetch-tags: true
87+
88+
- name: Download digests
89+
uses: actions/download-artifact@v4
90+
with:
91+
path: /tmp/digests
92+
pattern: digests-*
93+
merge-multiple: true
94+
95+
- name: Set up Docker Buildx
96+
uses: docker/setup-buildx-action@v3
97+
98+
- name: Log in to GitHub Container Registry
99+
uses: docker/login-action@v3
100+
with:
101+
registry: ghcr.io
102+
username: ${{ github.actor }}
103+
password: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Check if this commit has a release tag
106+
id: release
107+
run: |
108+
tag=$(git tag --points-at HEAD | grep '^v' | head -n1)
109+
if [ -n "$tag" ]; then
110+
echo "Found tag: $tag"
111+
if gh release view "$tag" --json tagName > /dev/null 2>&1; then
112+
echo "release_tag=$tag" >> $GITHUB_OUTPUT
113+
echo "is_release=true" >> $GITHUB_OUTPUT
114+
exit 0
115+
fi
116+
fi
117+
echo "is_release=false" >> $GITHUB_OUTPUT
118+
env:
119+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
120+
121+
- name: Generate tag list
122+
id: tags
123+
shell: bash
124+
run: |
125+
TAGS="type=sha"
126+
127+
if [ "${GITHUB_REF_TYPE}" = "branch" ] && [ "${GITHUB_REF_NAME}" = "main" ]; then
128+
TAGS="${TAGS}\ntype=raw,value=latest"
129+
fi
130+
131+
if [ "${{ steps.release.outputs.is_release }}" = "true" ]; then
132+
CLEAN_TAG=$(echo "${{ steps.release.outputs.release_tag }}" | sed 's/^v//')
133+
TAGS="${TAGS}\ntype=raw,value=${CLEAN_TAG}"
134+
fi
135+
136+
echo -e "tags<<EOF\n$TAGS\nEOF" >> $GITHUB_OUTPUT
137+
138+
- name: Extract image metadata
139+
id: meta
140+
uses: docker/metadata-action@v5
141+
with:
142+
images: ghcr.io/gaucho-racing/mapache/gr26
143+
tags: ${{ steps.tags.outputs.tags }}
144+
145+
- name: Create manifest list and push
146+
working-directory: /tmp/digests
147+
run: |
148+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
149+
$(printf 'ghcr.io/gaucho-racing/mapache/gr26@sha256:%s ' *)
150+
151+
- name: Inspect image
152+
run: |
153+
docker buildx imagetools inspect ghcr.io/gaucho-racing/mapache/gr26:${{ steps.meta.outputs.version }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
!example.env
44
*.env
5+
tmp/
56

67
# === K8S ===
78
k8s/db-config.yaml

docker-compose.yaml

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,32 +100,39 @@ services:
100100
RINCON_PASSWORD: "admin"
101101
RINCON_ENDPOINT: "http://rincon:10311"
102102

103-
# gr25:
104-
# image: gauchoracing/mp_gr25:latest
105-
# container_name: gr25
106-
# restart: unless-stopped
107-
# depends_on:
108-
# - nanomq
109-
# - rincon
110-
# ports:
111-
# - "7005:7005"
112-
# environment:
113-
# ENV: "DEV"
114-
# PORT: "7005"
115-
# SERVICE_ENDPOINT: "http://gr25:7005"
116-
# SERVICE_HEALTH_CHECK: "http://gr25:7005/gr25/ping"
117-
# MQTT_HOST: "nanomq"
118-
# MQTT_PORT: "1883"
119-
# MQTT_USER: "gr25"
120-
# MQTT_PASSWORD: "gr25"
121-
# DATABASE_HOST: ${DATABASE_HOST}
122-
# DATABASE_PORT: ${DATABASE_PORT}
123-
# DATABASE_NAME: ${DATABASE_NAME}
124-
# DATABASE_USER: ${DATABASE_USER}
125-
# DATABASE_PASSWORD: ${DATABASE_PASSWORD}
126-
# RINCON_USER: "admin"
127-
# RINCON_PASSWORD: "admin"
128-
# RINCON_ENDPOINT: "http://rincon:10311"
103+
gr26:
104+
build:
105+
context: .
106+
dockerfile: gr26/Dockerfile.dev
107+
container_name: gr26
108+
restart: unless-stopped
109+
depends_on:
110+
- rincon
111+
- nanomq
112+
ports:
113+
- "7005:7005"
114+
volumes:
115+
- ./gr26:/app/gr26
116+
- ./mapache-go:/app/mapache-go
117+
- gr26_go_cache:/go
118+
environment:
119+
ENV: "DEV"
120+
PORT: "7005"
121+
SERVICE_ENDPOINT: "http://gr26:7005"
122+
SERVICE_HEALTH_CHECK: "http://gr26:7005/gr26/ping"
123+
MQTT_HOST: "nanomq"
124+
MQTT_PORT: "1883"
125+
MQTT_USER: "gr26"
126+
MQTT_PASSWORD: "gr26"
127+
DATABASE_HOST: ${DATABASE_HOST}
128+
DATABASE_PORT: ${DATABASE_PORT}
129+
DATABASE_NAME: ${DATABASE_NAME}
130+
DATABASE_USER: ${DATABASE_USER}
131+
DATABASE_PASSWORD: ${DATABASE_PASSWORD}
132+
RINCON_USER: "admin"
133+
RINCON_PASSWORD: "admin"
134+
RINCON_ENDPOINT: "http://rincon:10311"
135+
SKIP_AUTH_CHECK: "true"
129136

130137
# query:
131138
# image: gauchoracing/mp_query:latest
@@ -172,4 +179,5 @@ services:
172179
volumes:
173180
pgdata:
174181
auth_go_cache:
175-
vehicle_go_cache:
182+
vehicle_go_cache:
183+
gr26_go_cache:

gr26/.air.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = "."
2+
tmp_dir = "tmp"
3+
4+
[build]
5+
bin = "./tmp/main"
6+
cmd = "go mod tidy && go build -o ./tmp/main ."
7+
delay = 1000
8+
exclude_dir = ["tmp", "vendor"]
9+
exclude_regex = ["_test.go"]
10+
include_ext = ["go", "toml"]
11+
kill_delay = "0s"
12+
send_interrupt = false
13+
poll = true
14+
poll_interval = 500
15+
stop_on_error = true
16+
17+
[log]
18+
time = false
19+
20+
[misc]
21+
clean_on_exit = true

0 commit comments

Comments
 (0)