Justfile templating
This commit is contained in:
parent
29c1fc8f82
commit
8d19a935d8
1 changed files with 19 additions and 7 deletions
26
justfile
26
justfile
|
@ -1,3 +1,15 @@
|
||||||
|
pg_pass := "password"
|
||||||
|
pg_user := "postgres"
|
||||||
|
pg_container := "postgres"
|
||||||
|
pg_port := "5432"
|
||||||
|
network := "fb_network"
|
||||||
|
db_name := "frostbyte"
|
||||||
|
|
||||||
|
conn_string := "postgres://" + pg_user + ":" + pg_pass + "@" + pg_container + ":" + pg_port / db_name
|
||||||
|
conn_local := "postgres://" + pg_user + ":" + pg_pass + "@" + "localhost" + ":" + pg_port / db_name
|
||||||
|
env_string := "DATABASE_URL=" + conn_string
|
||||||
|
env_local := "DATABASE_URL=" + conn_local
|
||||||
|
|
||||||
# Builds a debug container and runs it
|
# Builds a debug container and runs it
|
||||||
dev: start-debug
|
dev: start-debug
|
||||||
@echo "Cd into client and run 'npm run dev' to start the client in dev mode."
|
@echo "Cd into client and run 'npm run dev' to start the client in dev mode."
|
||||||
|
@ -10,8 +22,8 @@ build-container-server-debug:
|
||||||
# Builds a debug container and runs it
|
# Builds a debug container and runs it
|
||||||
[private]
|
[private]
|
||||||
start-debug: start-postgres-dev clean-podman init-sqlx build-container-server-debug
|
start-debug: start-postgres-dev clean-podman init-sqlx build-container-server-debug
|
||||||
podman network create fb_network --ignore
|
podman network create {{network}} --ignore
|
||||||
podman run -d --network fb_network -e DATABASE_URL=postgres://postgres:password@postgres:5432/frostbyte -p 8080:8080 --name frostbyte-debug fb-server-debug
|
podman run -d --network {{network}} -e {{env_string}} -p 8080:8080 --name frostbyte-debug fb-server-debug
|
||||||
@echo "Debug server started."
|
@echo "Debug server started."
|
||||||
|
|
||||||
# Builds a release container
|
# Builds a release container
|
||||||
|
@ -21,12 +33,12 @@ build-container-release:
|
||||||
|
|
||||||
# Builds a release container and runs it
|
# Builds a release container and runs it
|
||||||
start-release: start-postgres-dev clean-podman init-sqlx build-container-release
|
start-release: start-postgres-dev clean-podman init-sqlx build-container-release
|
||||||
podman network create fb_network --ignore
|
podman network create {{network}} --ignore
|
||||||
podman run -d --network fb_network -e DATABASE_URL=postgres://postgres:password@postgres:5432/frostbyte -p 8080:8080 --name frostbyte fb-server
|
podman run -d --network {{network}} -e {{env_string}} -p 8080:8080 --name frostbyte fb-server
|
||||||
|
|
||||||
# Initializes the database, runs migrations and then prepares sqlx
|
# Initializes the database, runs migrations and then prepares sqlx
|
||||||
init-sqlx:
|
init-sqlx:
|
||||||
echo "DATABASE_URL=postgres://postgres:password@localhost:5432/frostbyte" > server/.env
|
echo {{env_local}} > server/.env
|
||||||
cd server && sqlx database create --connect-timeout 40 # Postgres takes a while to start up
|
cd server && sqlx database create --connect-timeout 40 # Postgres takes a while to start up
|
||||||
cd server && sqlx migrate run --source migrations_pg
|
cd server && sqlx migrate run --source migrations_pg
|
||||||
cd server && cargo sqlx prepare
|
cd server && cargo sqlx prepare
|
||||||
|
@ -34,8 +46,8 @@ init-sqlx:
|
||||||
# Starts a postgres container for development
|
# Starts a postgres container for development
|
||||||
[private]
|
[private]
|
||||||
start-postgres-dev:
|
start-postgres-dev:
|
||||||
podman rm -f postgres
|
podman rm -f {{pg_container}}
|
||||||
podman run --network fb_network --name postgres -e POSTGRES_PASSWORD=password -d -p 5432:5432 docker.io/postgres:16.1-alpine
|
podman run --network {{network}} --name {{pg_container}} -e POSTGRES_PASSWORD={{pg_pass}} -d -p {{pg_port}}:5432 docker.io/postgres:16.1-alpine
|
||||||
|
|
||||||
# Forcefully stops and removes the frostbyte container
|
# Forcefully stops and removes the frostbyte container
|
||||||
[private]
|
[private]
|
||||||
|
|
Loading…
Reference in a new issue