DEVELOPMENT ENVIRONMENT

~liljamo/tixe

3b3bb7f5ef08abbd8327dc0092c38feb04e6c84e — Jonni Liljamo 1 year, 20 days ago d450fba
feat: add dev docker-compose that runs the app with air
4 files changed, 65 insertions(+), 1 deletions(-)

A .air.toml
M .gitignore
M dev.elv
A docker-compose.dev.yaml
A .air.toml => .air.toml +6 -0
@@ 0,0 1,6 @@
root = "."
tmp_dir = "tmp"

[build]
cmd = "go build -buildvcs=false -o ./tmp/tixe ."
bin = "tmp/tixe"

M .gitignore => .gitignore +3 -0
@@ 1,2 1,5 @@
# executable
tixe

# air tmp
tmp/

M dev.elv => dev.elv +8 -1
@@ 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
        }

A docker-compose.dev.yaml => docker-compose.dev.yaml +48 -0
@@ 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