DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: e8e1276a35ebfeeb0439849fd89eb3ca3b9f90be deck-builder/api/dev-launch.sh -rwxr-xr-x 1.0 KiB
e8e1276aJonni Liljamo feat(client): kinda cleanup seed_gen usage 1 year, 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

export COMPOSE_PROJECT_NAME=laurelinapi

function confirm() {
  echo -n "$@ [y/N]: "
    read -e answer
    for response in y Y
    do
        if [ "_$answer" == "_$response" ]
        then
            return 0
        fi
    done

    # default to no
    return 1
}

function dockerlaunch() {
  confirm reset containers? && docker compose down
  confirm reset database? && docker volume rm laurelinapi_apidb_data

  confirm rebuild api? && docker compose build

  confirm launch? && docker compose up
}

function nixenv() {
  nix develop
}

function nixsetup() {
  export PGDATA=/tmp/laurelinpgdata
  initdb
  pg_ctl -o "-k /tmp" start
  createdb -h /tmp laurelinapi

  export GIN_MODE=release # or "debug" for debug logs
  export LAURELINAPI_JWT_SECRET=XpNYdG7vgvgPPuezrtZqt4CJIUuxNP7c
  export GORM_DB_STRING="host=localhost dbname=laurelinapi port=5432 sslmode=disable"

  go run main.go
}

if confirm nix?
then
  if confirm "in devshell?"
  then
    nixsetup
  else
    nixenv
  fi
else
  dockerlaunch
fi