Skip to content

Commit

Permalink
chore: replace tmate with zellij
Browse files Browse the repository at this point in the history
use a simpler declarative workspace
  • Loading branch information
BobyMCbobs committed Jul 27, 2024
1 parent db564d1 commit b2e3900
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 32 deletions.
20 changes: 20 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ Requirements:
- [nodejs](https://nodejs.org/en/download/)
- a [Postgres](https://www.postgresql.org/download/) database

## Install dependencies with Brew

```sh
brew install go nodejs npm
```

## Launch a workspace with Zellij

install with Brew

```sh
brew install zellij
```

launch the workspace

```sh
./hack/start-dev.sh
```

## Set up Postgres

Docker/Podman:
Expand Down
37 changes: 37 additions & 0 deletions hack/dev.kdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
layout {
default_tab_template {
pane size=1 borderless=true {
plugin location="zellij:tab-bar"
}
children
pane size=2 borderless=true {
plugin location="zellij:status-bar"
}
}
pane_template name="postgres" {
command "podman"
args "compose" "--file" "./deployments/docker-compose-dev.yml" "up"
}
pane_template name="backend" {
command "gow"
args "run" "."
focus true
}
pane_template name="frontend" {
command "npm"
args "run" "build-watch"
cwd "./web/"
focus true
}
tab name="postgres" {
postgres
}
tab name="backend" split_direction="vertical" {
backend
pane
}
tab name="frontend" split_direction="vertical" {
frontend
pane
}
}
33 changes: 1 addition & 32 deletions hack/start-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,4 @@
cd $(dirname $0)
cd $(git rev-parse --show-toplevel)

CONTAINER_RUNTIME="${1:-podman}"
TMATE_SOCKET="/tmp/tmate-flattrack-${USER}-${RANDOM}"

IMAGE_POSTGRES=postgres:16.1-alpine3.19
IMAGE_MINIO=minio/minio:RELEASE.2023-06-29T05-12-28Z

(
until tmate -S "${TMATE_SOCKET}" wait-for tmate-ready; do
echo "Waiting"
sleep 1
done
tmate -F -v -S "${TMATE_SOCKET}" new-window -d -c "$PWD" -n ft-pg bash
tmate -S "${TMATE_SOCKET}" send-keys -t ft-pg "${CONTAINER_RUNTIME} run -it --rm --env-file .env --name flattrack-postgres -p 5432:5432 ${IMAGE_POSTGRES}" Enter

tmate -F -v -S "${TMATE_SOCKET}" new-window -d -c "$PWD" -n ft-pg-psql bash
tmate -S "${TMATE_SOCKET}" send-keys -t ft-pg-psql "until nc -zv localhost 5432; do sleep 1s; done" Enter
tmate -S "${TMATE_SOCKET}" send-keys -t ft-pg-psql "${CONTAINER_RUNTIME} exec -it flattrack-postgres psql" Enter

tmate -F -v -S "${TMATE_SOCKET}" new-window -d -c "$PWD" -n ft-minio bash
tmate -S "${TMATE_SOCKET}" send-keys \
-t ft-minio \
"${CONTAINER_RUNTIME} run -it --rm --env-file .env -p 9000:9000 -p 9001:9001 ${IMAGE_MINIO} server /data --console-address \":9001\"" Enter

sleep 2s
tmate -F -v -S "${TMATE_SOCKET}" new-window -d -c "$PWD" -n ft-backend bash
tmate -S "${TMATE_SOCKET}" send-keys -t ft-backend "go run ." Enter

tmate -F -v -S "${TMATE_SOCKET}" new-window -d -c "$PWD/web" -n ft-frontend bash
tmate -S "${TMATE_SOCKET}" send-keys -t ft-frontend "npm run build" Enter
) &

tmate -S "${TMATE_SOCKET}"
zellij --layout=./hack/dev.kdl

0 comments on commit b2e3900

Please sign in to comment.