From 3b3bb7f5ef08abbd8327dc0092c38feb04e6c84e Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Thu, 31 Aug 2023 11:03:53 +0300 Subject: [PATCH] feat: add dev docker-compose that runs the app with air --- .air.toml | 6 ++++++ .gitignore | 3 +++ dev.elv | 9 +++++++- docker-compose.dev.yaml | 48 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .air.toml create mode 100644 docker-compose.dev.yaml diff --git a/.air.toml b/.air.toml new file mode 100644 index 0000000..7e58bbb --- /dev/null +++ b/.air.toml @@ -0,0 +1,6 @@ +root = "." +tmp_dir = "tmp" + +[build] +cmd = "go build -buildvcs=false -o ./tmp/tixe ." +bin = "tmp/tixe" diff --git a/.gitignore b/.gitignore index d05c4f8..c9f642e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # executable tixe + +# air tmp +tmp/ diff --git a/dev.elv b/dev.elv index 5cf8d76..5ef6d4b 100755 --- a/dev.elv +++ b/dev.elv @@ -5,6 +5,11 @@ fn run { docker compose up --build } +fn run_air { + clear + docker compose -f ./docker-compose.dev.yaml up +} + fn clean { clear docker compose down @@ -14,11 +19,13 @@ fn clean { fn docker_menu { var input while (not-eq $input "b") { - echo "[R]un, [C]lean, [B]ack" + echo "[R]un, Run [A]ir, [C]lean, [B]ack" set input = (sh -c 'read -n1 && echo $REPLY' | take 1) if (eq $input "r") { run + } elif (eq $input "a") { + run_air } elif (eq $input "c") { clean } diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml new file mode 100644 index 0000000..3038401 --- /dev/null +++ b/docker-compose.dev.yaml @@ -0,0 +1,48 @@ +version: "3.8" + +networks: + internal: + external: false + +volumes: + tixedb_data: + driver: local + +services: + tixedb: + image: postgres:15-alpine + container_name: tixedb + restart: always + networks: + - internal + volumes: + - tixedb_data:/var/lib/postgresql/data + environment: + POSTGRES_USER: tixe + POSTGRES_PASSWORD: tixe + POSTGRES_DB: tixe + + tixeair: + image: cosmtrek/air + working_dir: /tixesrc + container_name: tixeair + restart: always + networks: + - internal + ports: + - 8080:8080 + volumes: + - ./:/tixesrc + environment: + TZ: Europe/Helsinki + GIN_MODE: release # or "debug" for debug logs + TIXE_PSQL_HOST: tixedb + TIXE_PSQL_USER: tixe + TIXE_PSQL_PASSWORD: tixe + TIXE_PSQL_DB: tixe + TIXE_COOKIE_SECRET: secret + TIXE_OIDC_DOMAIN: auth.example.com + TIXE_OIDC_CLIENTID: tixeclient + TIXE_OIDC_SECRET: secret + depends_on: + - tixedb -- 2.44.1