-
Notifications
You must be signed in to change notification settings - Fork 5
/
justfile
141 lines (106 loc) · 2.63 KB
/
justfile
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
set export := true
set dotenv-load := true
# --------------
# Internal Use
# Or
# Documentation
# --------------
# Application
database := justfile_directory() + "server/database"
server := justfile_directory() + "/server"
client := justfile_directory() + "/client"
server_port := "8080"
# Deploy
deploy_host := env_var_or_default("DEPLOY_HOST", "NONE")
# Utils
replace := if os() == "linux" { "sed -i" } else { "sed -i '' -e" }
# Lists all availiable targets
default:
just --list
# ---------
# Database
# ---------
# Login into the local Database as `admin`
db:
psql -U admin mmo
# Bootstraps the local nix-based postgres server
postgres:
devenv up
# -------
# Client
# -------
format:
zig fmt .
client:
cd client && zig build run
client-release:
cd client && zig build run --release=fast
client-build:
cd client && zig build
client-test:
cd client && zig build test
client-build-ci:
cd client && zig build -fsys=raylib
client-test-ci:
cd client && zig build test -fsys=raylib
client-deps:
cd client && nix run github:Cloudef/zig2nix#zon2nix -- build.zig.zon > zon-deps.nix
# --------
# Backend
# --------
build:
cd server && rebar3 compile
# Fetches rebar3 dependencies, updates both the rebar and nix lockfiles
deps:
cd server && rebar3 get-deps
cd server && rebar3 nix lock
# Runs ther erlang server (inside the rebar shell)
server: build
cd server && rebar3 shell
# Runs unit tests in the server
test:
cd server && rebar3 do eunit, ct
# Migrates the DB (up)
db-up:
./server/database/migrate_up.sh
# Nukes the DB
db-down:
./server/database/migrate_down.sh
# Populate DB
db-input:
./server/database/migrate_input.sh
# Hard reset DB
db-reset: db-down db-up db-input
# --------
# Releases
# --------
# Create a prod release of the server
release: deps
rebar3 as prod release
# Create a prod release (for nix) of the server
release-nix:
rebar3 as prod tar
# ----------
# Deployment
# ----------
# Builds the deployment docker image with Nix
build-docker:
nix build .#dockerImage
# Builds and deploys a release in the host VM
deploy:
@echo "Attemping to deploy to: {{deploy_host}}"
./deploy.sh --deploy-host {{deploy_host}}
# Jump into an erlang shell to debug the server (dont do this, srlsy)
shell:
cd server && rebar3 shell
# Starts the deployed code
start:
#!/usr/bin/env bash
export SERVER_APP=lyceum_server
export ERL_DIST_PORT=8080
if [[ $(./result/bin/$SERVER_APP ping) == "pong" ]]; then
./result/bin/$SERVER_APP stop
./result/bin/$SERVER_APP foreground
else
./result/bin/$SERVER_APP foreground
fi