2024-02-10 17:05:11 +00:00
|
|
|
# Always use devbox environment to run commands.
|
|
|
|
set shell := ["devbox", "run"]
|
2024-02-11 19:28:00 +00:00
|
|
|
# Load dotenv
|
|
|
|
set dotenv-load
|
2024-02-10 17:05:11 +00:00
|
|
|
|
2024-02-18 21:37:17 +00:00
|
|
|
# Load public and private keys
|
2024-02-18 21:42:47 +00:00
|
|
|
export JWT_PRIVATE_KEY := `cat jwt.private.pem || echo ""`
|
|
|
|
export JWT_PUBLIC_KEY := `cat jwt.public.pem || echo ""`
|
2024-02-18 21:37:17 +00:00
|
|
|
|
2024-02-18 07:51:05 +00:00
|
|
|
GIT_SHA := `git rev-parse --short HEAD`
|
|
|
|
DOCKER_IMAGE := "ghcr.io/mentos1386/zdravko:sha-"+GIT_SHA
|
2024-06-02 19:53:51 +00:00
|
|
|
|
2024-02-12 08:25:11 +00:00
|
|
|
STATIC_DIR := "./web/static"
|
2024-02-10 11:59:58 +00:00
|
|
|
|
2024-06-02 19:53:51 +00:00
|
|
|
OS := "linux darwin"
|
|
|
|
ARCH := "amd64 arm64"
|
|
|
|
|
|
|
|
export CGO_ENABLED := "0"
|
|
|
|
import 'build/Justfile'
|
|
|
|
|
2024-02-19 09:09:30 +00:00
|
|
|
_default:
|
|
|
|
@just --list
|
2024-02-18 10:34:03 +00:00
|
|
|
|
2024-02-11 10:56:21 +00:00
|
|
|
# Run full development environment
|
|
|
|
run:
|
2024-05-28 17:59:44 +00:00
|
|
|
watchexec -r -e tmpl,css just tailwindcss | sed -e 's/^/tailwind: /;' &
|
2024-02-27 11:04:05 +00:00
|
|
|
sleep 1
|
2024-02-24 21:07:49 +00:00
|
|
|
just run-temporal | sed -e 's/^/temporal: /;' &
|
2024-02-27 11:04:05 +00:00
|
|
|
sleep 1
|
2024-02-24 21:07:49 +00:00
|
|
|
watchexec -r -e go,tmpl,css just run-server
|
2024-02-10 11:59:58 +00:00
|
|
|
|
2024-02-19 09:09:30 +00:00
|
|
|
# Start worker
|
2024-02-18 21:37:17 +00:00
|
|
|
run-worker:
|
2024-05-28 17:59:44 +00:00
|
|
|
go run cmd/zdravko/main.go --worker
|
2024-02-18 21:41:40 +00:00
|
|
|
|
2024-02-19 09:09:30 +00:00
|
|
|
# Start server
|
|
|
|
run-server:
|
2024-05-28 17:59:44 +00:00
|
|
|
go run cmd/zdravko/main.go --server
|
2024-02-20 10:24:04 +00:00
|
|
|
|
|
|
|
# Start temporal
|
|
|
|
run-temporal:
|
2024-05-28 17:59:44 +00:00
|
|
|
go run cmd/zdravko/main.go --temporal
|
2024-02-18 21:37:17 +00:00
|
|
|
|
2024-02-21 08:41:49 +00:00
|
|
|
# Test
|
|
|
|
test:
|
2024-02-21 22:15:21 +00:00
|
|
|
go test -v ./...
|
2024-02-21 08:41:49 +00:00
|
|
|
|
2024-02-18 21:37:17 +00:00
|
|
|
# Generates new jwt key pair
|
|
|
|
generate-jwt-key:
|
2024-05-23 18:34:52 +00:00
|
|
|
openssl genrsa -out jwt.private.pem 2048
|
|
|
|
openssl rsa -pubout -in jwt.private.pem -out jwt.public.pem
|
2024-02-18 21:37:17 +00:00
|
|
|
|
2024-02-19 09:09:30 +00:00
|
|
|
# Run Docker application.
|
2024-06-02 19:53:51 +00:00
|
|
|
run-docker: build-docker
|
2024-02-19 09:09:30 +00:00
|
|
|
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 \
|
2024-06-02 19:53:51 +00:00
|
|
|
-e WORKER_GROUP_TOKEN \
|
2024-02-19 09:09:30 +00:00
|
|
|
{{DOCKER_IMAGE}} --server --temporal --worker
|
2024-02-18 22:11:42 +00:00
|
|
|
|
2024-02-27 11:04:05 +00:00
|
|
|
# Start Sqlite web client
|
|
|
|
sqlite-web:
|
|
|
|
sqlite_web zdravko.db
|
2024-02-11 10:56:21 +00:00
|
|
|
|
2024-04-28 19:24:00 +00:00
|
|
|
# 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"
|
|
|
|
|
2024-06-02 19:53:51 +00:00
|
|
|
update-dependencies:
|
|
|
|
go get -u -t \
|
|
|
|
go.k6.io/k6@v0.51.0 \
|
2024-06-03 19:28:16 +00:00
|
|
|
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 \
|
2024-06-02 19:53:51 +00:00
|
|
|
./...
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
# Run go generate and process tailwindcss
|
|
|
|
generate: tailwindcss
|
2024-02-11 10:56:21 +00:00
|
|
|
go generate ./...
|
|
|
|
|
2024-05-28 17:59:44 +00:00
|
|
|
tailwindcss:
|
|
|
|
mkdir -p {{STATIC_DIR}}/css
|
2024-06-02 19:53:51 +00:00
|
|
|
tailwindcss build -c build/tailwind.config.js -i {{STATIC_DIR}}/css/main.css -o {{STATIC_DIR}}/css/tailwind.css
|
2024-05-28 17:59:44 +00:00
|
|
|
|
2024-06-02 19:53:51 +00:00
|
|
|
static-dependencies:
|
2024-05-28 17:59:44 +00:00
|
|
|
npm install
|
2024-02-11 10:56:21 +00:00
|
|
|
|
2024-06-02 19:53:51 +00:00
|
|
|
static-clean:
|
|
|
|
find {{STATIC_DIR}} -type f -not -path '{{STATIC_DIR}}/static.go' -not -path '{{STATIC_DIR}}/css/*' -exec rm -f {} \;
|
2024-02-11 10:56:21 +00:00
|
|
|
|
2024-06-02 19:53:51 +00:00
|
|
|
static: static-dependencies static-clean tailwindcss
|
2024-05-28 17:59:44 +00:00
|
|
|
# HTMX
|
|
|
|
mkdir -p {{STATIC_DIR}}/js
|
|
|
|
cp node_modules/htmx.org/dist/htmx.min.js {{STATIC_DIR}}/js/htmx.min.js
|
2024-02-21 22:15:21 +00:00
|
|
|
|
2024-05-28 17:59:44 +00:00
|
|
|
# Monaco
|
|
|
|
cp -r node_modules/monaco-editor/min/* {{STATIC_DIR}}/monaco
|
2024-05-23 16:33:30 +00:00
|
|
|
# We only care about javascript language
|
2024-02-21 22:15:21 +00:00
|
|
|
find {{STATIC_DIR}}/monaco/vs/basic-languages/ \
|
|
|
|
-type d \
|
|
|
|
-not -name 'javascript' \
|
|
|
|
-not -name 'typescript' \
|
2024-05-23 16:33:30 +00:00
|
|
|
-not -name 'yaml' \
|
2024-02-21 22:15:21 +00:00
|
|
|
-not -name 'basic-languages' \
|
|
|
|
-prune -exec rm -rf {} \;
|
|
|
|
|
2024-05-28 17:59:44 +00:00
|
|
|
# Feather Icons
|
2024-02-11 10:56:21 +00:00
|
|
|
mkdir -p {{STATIC_DIR}}/icons
|
2024-05-28 17:59:44 +00:00
|
|
|
cp node_modules/feather-icons/dist/feather-sprite.svg {{STATIC_DIR}}/icons/feather-sprite.svg
|