Skip to content

Commit

Permalink
fixup! feat: CI build process for grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
madwort committed Nov 15, 2023
1 parent 7e8fa25 commit 2bf12c3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:
with:
install-just: true

- name: Build docker image for both prod and dev
- name: Build docker image
run: |
just grafana/build
- name: Run smoke test
run: |
just grafana/serve
sleep 5
just grafana/smoke-test || { docker logs grafana_1; exit 1; }
sleep 10
just grafana/smoke-test || { docker logs grafana-grafana_1; exit 1; }
- name: Save docker image
run: |
Expand Down Expand Up @@ -95,8 +95,8 @@ jobs:
- name: Test image we imported from previous job works
run: |
SKIP_BUILD=1 just grafana/serve
sleep 5
just grafana/smoke-test || { docker logs grafana_1; exit 1; }
sleep 10
just grafana/smoke-test || { docker logs grafana-grafana_1; exit 1; }
- name: Publish image
run: |
Expand Down
33 changes: 33 additions & 0 deletions grafana/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
services:
db:
image: "postgres:16"
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: pass
POSTGRES_DB: grafana
ports:
- "6543:5432"
volumes:
- postgres:/var/lib/postgresql/data/

grafana:
# use Dockerfile so that version matches production
build:
dockerfile: Dockerfile
environment:
GF_DATABASE_TYPE: postgres
GF_DATABASE_HOST: db:5432
GF_DATABASE_NAME: grafana
GF_DATABASE_USER: user
GF_DATABASE_PASSWORD: pass
GF_DATABASE_SSL_MODE: disable
depends_on:
- db
ports:
- 3000:3000
volumes:
- grafana:/var/lib/grafana

volumes:
postgres:
grafana:
7 changes: 4 additions & 3 deletions grafana/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ build:
export GITREF=$(git rev-parse --short HEAD)

# build the thing
docker build .
docker compose build grafana

serve:
# Do a basic test with built-in sqlitedb
docker run -p 3000:3000 sha256:c9af59530625894c962e8516cfd44f61161c8dee70fa7e5a7fd78d971c4429b5
# this should use the Dockerfile version, or this test is pointless
docker compose up grafana -d

# run a basic functional smoke test against a running server
smoke-test host="http://localhost:3000/login":
smoke-test host="http://127.0.0.1:3000/login":
#!/bin/bash
set -eu
curl -I {{ host }} -s --compressed --fail --retry 20 --retry-delay 1 --retry-all-errors
Expand Down

0 comments on commit 2bf12c3

Please sign in to comment.