Skip to content

Commit 648ed67

Browse files
author
Anze
committed
Merge branch 'feature/multiplatform'
2 parents 0c16c3e + 3a3f4af commit 648ed67

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
BACKEND_URL=https://grafolean.com/api
1+
BACKEND_URL=https://app.grafolean.com/api
22
BOT_TOKEN=
33
JOBS_REFRESH_INTERVAL=120
44
DB_DIR=
5+
# only matters if database is not started via docker-compose:
56
DB_HOST=
67
DB_DATABASE=
78
DB_USERNAME=

.github/workflows/on_release.yml

+16-6
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,33 @@ jobs:
1313
- name: Checkout source code
1414
uses: actions/checkout@v1
1515

16+
- name: Set up QEMU for more platforms
17+
uses: docker/setup-qemu-action@v1
18+
with:
19+
platforms: all
1620

17-
- name: Deploy to Docker Hub
21+
- name: Set docker build as alias to buildx (multiarch build)
22+
uses: docker/setup-buildx-action@v1
23+
id: buildx
24+
with:
25+
install: false
26+
27+
- name: Deploy to Docker Hub - multiplatform
1828
if: success() && startsWith(github.ref, 'refs/tags/v')
1929
env:
2030
GITHUB_REF_TAG: ${{ github.ref }}
2131
DOCKER_REGISTRY: docker.io
2232
DOCKER_IMAGE: grafolean/grafolean-snmp-bot
2333
DOCKER_USER: grafolean
2434
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
35+
BUILD_PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64
2536
run: |
37+
echo "Available plaftorms: ${{ steps.buildx.outputs.platforms }}"
38+
echo "Building for plaftorms: $BUILD_PLATFORMS"
2639
export VERSION=${GITHUB_REF_TAG:10:50}
2740
echo "Version is $VERSION"
2841
export LAST_KNOWN_VERSION=`git tag -l --sort=-version:refname "v*.*.*" | grep -v rc | head -n 1 | tr -d '[:space:]'`
2942
echo "Last known version is $LAST_KNOWN_VERSION"
3043
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD $DOCKER_REGISTRY
31-
docker build -t "docker.io/$DOCKER_IMAGE:$VERSION" -t "docker.io/$DOCKER_IMAGE:latest" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') .
32-
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker tag "docker.io/$DOCKER_IMAGE:$VERSION" "docker.io/$DOCKER_IMAGE:latest" || echo "NOT MARKING AS LATEST!"
33-
docker images
34-
docker push "docker.io/$DOCKER_IMAGE:$VERSION"
35-
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker push "docker.io/$DOCKER_IMAGE:latest" || echo "NOT LATEST!"
44+
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && echo "MARKING AS LATEST!" || echo "NOT MARKING AS LATEST!"
45+
[ "$LAST_KNOWN_VERSION" == "$VERSION" ] && docker buildx build --push --platform "$BUILD_PLATFORMS" -t "docker.io/$DOCKER_IMAGE:$VERSION" -t "docker.io/$DOCKER_IMAGE:latest" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') . || docker buildx build --push --platform "$BUILD_PLATFORMS" -t "docker.io/$DOCKER_IMAGE:$VERSION" --build-arg VERSION=$VERSION --build-arg VCS_REF=$GITHUB_SHA --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') .

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ LABEL org.label-schema.vendor="Grafolean" \
3131
COPY --from=python-requirements /requirements.txt /requirements.txt
3232
RUN \
3333
apt-get update && \
34-
apt-get install --no-install-recommends -q -y libsnmp-dev build-essential git && \
34+
apt-get install --no-install-recommends -q -y libsnmp-dev build-essential libpq-dev python3-dev git snmp && \
3535
pip install --no-cache-dir -r /requirements.txt && \
36-
apt-get purge -y build-essential && \
36+
apt-get purge -y build-essential libpq-dev python3-dev && \
3737
apt-get clean autoclean && \
3838
apt-get autoremove --yes && \
3939
rm -rf /var/lib/{apt,dpkg,cache,log}/ && \

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636

3737

3838
db:
39-
image: postgres:12.1-alpine
39+
image: timescale/timescaledb:latest-pg12
4040
container_name: grafolean-snmp-db
4141
volumes:
4242
# You should always save DB data to a host directory unless you are prepared to lose it. By default
@@ -50,7 +50,7 @@ services:
5050
- POSTGRES_PASSWORD=${DB_PASS:-admin}
5151
restart: always
5252
healthcheck:
53-
test: ["CMD-SHELL", "pg_isready -h db -t 1 -q"]
53+
test: ["CMD-SHELL", "pg_isready -h db -U ${DB_USER:-admin} -t 1 -q"]
5454
interval: 10s
5555
timeout: 5s
5656
retries: 3

snmpbot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ def jobs(self):
428428

429429

430430
def wait_for_grafolean(backend_url):
431+
url = '{}/status/info'.format(backend_url)
431432
while True:
432-
url = '{}/status/info'.format(backend_url)
433433
log.info("Checking Grafolean status...")
434434
try:
435435
r = requests.get(url)
@@ -440,7 +440,7 @@ def wait_for_grafolean(backend_url):
440440
return
441441
except:
442442
pass
443-
log.info("Grafolean backend not available / initialized yet, waiting.")
443+
log.info(f"Grafolean backend (url: {url}) not available / initialized yet, waiting.")
444444
time.sleep(10)
445445

446446

0 commit comments

Comments
 (0)