-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
135 lines (110 loc) · 3.6 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
# Always use devbox environment to run commands.
set shell := ["devbox", "run"]
# Load dotenv
set dotenv-load
# Load public and private keys
export JWT_PRIVATE_KEY := `cat jwt.private.pem || echo ""`
export JWT_PUBLIC_KEY := `cat jwt.public.pem || echo ""`
DOCKER_REGISTRY := "ghcr.io/mentos1386/zdravko"
GIT_SHA := `git rev-parse --short HEAD`
DOCKER_IMAGE := "{{ DOCKER_REGISTRY }}:sha-{{ GIT_SHA }}"
STATIC_DIR := "./web/static"
export CGO_ENABLED := "0"
import 'build/Justfile'
import 'deploy/Justfile'
_default:
@just --list
# Run full development environment
run:
watchexec -r -e tmpl,css just tailwindcss | sed -e 's/^/tailwind: /;' &
sleep 1
just run-temporal | sed -e 's/^/temporal: /;' &
sleep 1
watchexec -r -e go,tmpl,css just run-server
# Start worker
run-worker:
go run cmd/zdravko/main.go --worker
# Start server
run-server:
go run cmd/zdravko/main.go --server
# Start temporal
run-temporal:
go run cmd/zdravko/main.go --temporal
# Test
test:
go test -v ./...
# Generates new jwt key pair
generate-jwt-key:
openssl genrsa -out jwt.private.pem 2048
openssl rsa -pubout -in jwt.private.pem -out jwt.public.pem
# Run Docker application.
run-docker: build
docker run -p 8080:8080 \
-it --rm \
-e SESSION_SECRET \
-e OAUTH2_CLIENT_ID \
-e OAUTH2_CLIENT_SECRET \
-e OAUTH2_ENDPOINT_TOKEN_URL \
-e OAUTH2_ENDPOINT_AUTH_URL \
-e OAUTH2_ENDPOINT_USER_INFO_URL \
-e OAUTH2_ENDPOINT_LOGOUT_URL \
-e JWT_PRIVATE_KEY \
-e JWT_PUBLIC_KEY \
-e WORKER_GROUP_TOKEN \
{{DOCKER_IMAGE}} --server --temporal --worker
# Start Sqlite web client
sqlite-web:
sqlite_web zdravko.db
# New migration file
migration-new name:
#!/bin/bash
FILENAME="database/sqlite/migrations/`date --iso-8601`_{{name}}.sql"
cat <<EOF > $FILENAME
-- +migrate Up
-- SQL in section 'Up' is executed when this migration is applied
-- +migrate Down
-- SQL in section 'Down' is executed when this migration is rolled back
EOF
echo "Created migration file: $FILENAME"
update-dependencies:
# Updating temporal dependencies is a bit tricky
# as finding the right combination of api, server and ui-server
# that work together is not easy.
# Any version of ui-server > 2.23.0 < 2.27.2 is broken for us.
# Using latest of everything results (at the time of writing) in to
# working server but broken ui-server (404 when it tries to list namespaces).
go get -u -t \
go.k6.io/k6@v0.51.0 \
github.com/temporalio/ui-server/v2@v2.23.0 \
go.temporal.io/server@v1.23.0 \
go.temporal.io/api@v1.29.2 \
go.temporal.io/sdk@v1.26.0 \
./...
go mod tidy
# Run go generate and process tailwindcss
generate: tailwindcss
go generate ./...
tailwindcss:
mkdir -p {{STATIC_DIR}}/css
tailwindcss build -c build/tailwind.config.js -i {{STATIC_DIR}}/css/main.css -o {{STATIC_DIR}}/css/tailwind.css
static-dependencies:
npm install
static-clean:
find {{STATIC_DIR}} -type f -not -path '{{STATIC_DIR}}/static.go' -not -path '{{STATIC_DIR}}/css/*' -exec rm -f {} \;
static: static-dependencies static-clean tailwindcss
# HTMX
mkdir -p {{STATIC_DIR}}/js
cp node_modules/htmx.org/dist/htmx.min.js {{STATIC_DIR}}/js/htmx.min.js
# Monaco
cp -r node_modules/monaco-editor/min/* {{STATIC_DIR}}/monaco
# We only care about javascript language
find {{STATIC_DIR}}/monaco/vs/basic-languages/ \
-type d \
-not -name 'javascript' \
-not -name 'typescript' \
-not -name 'yaml' \
-not -name 'basic-languages' \
-prune -exec rm -rf {} \;
# Feather Icons
mkdir -p {{STATIC_DIR}}/icons
cp node_modules/feather-icons/dist/feather-sprite.svg {{STATIC_DIR}}/icons/feather-sprite.svg