FrostByte/justfile

75 lines
2.6 KiB
Makefile
Raw Normal View History

2023-11-14 09:00:25 +01:00
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
dev: start-debug
@echo "Cd into client and run 'npm run dev' to start the client in dev mode."
# Builds a debug container
2023-10-20 00:56:57 +02:00
[private]
build-container-server-debug:
podman build -t fb-server-debug -f container/ContainerfileDebug .
# Builds a debug container and runs it
2023-10-20 00:56:57 +02:00
[private]
start-debug: start-postgres-dev clean-podman init-sqlx build-container-server-debug
2023-11-14 09:00:25 +01:00
podman network create {{network}} --ignore
podman run -d --network {{network}} -e {{env_string}} -p 8080:8080 --name frostbyte-debug fb-server-debug
@echo "Debug server started."
# Builds a release container
2023-10-20 00:56:57 +02:00
[private]
build-container-release:
podman build -t fb-server -f container/Containerfile .
# Builds a release container and runs it
2023-11-22 15:40:29 +01:00
start-release: start-postgres-dev clean-podman init-sqlx build-container-release create-network
2023-11-14 09:00:25 +01:00
podman run -d --network {{network}} -e {{env_string}} -p 8080:8080 --name frostbyte fb-server
2023-10-20 00:56:57 +02:00
# Initializes the database, runs migrations and then prepares sqlx
init-sqlx:
2023-11-14 09:00:25 +01:00
echo {{env_local}} > server/.env
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 && cargo sqlx prepare
# Starts a postgres container for development
[private]
2023-11-22 15:40:29 +01:00
start-postgres-dev: create-network
2023-11-14 09:00:25 +01:00
podman rm -f {{pg_container}}
podman run --network {{network}} --name {{pg_container}} -e POSTGRES_PASSWORD={{pg_pass}} -d -p {{pg_port}}:5432 docker.io/postgres:16.1-alpine
2023-11-22 15:40:29 +01:00
[private]
create-network:
podman network create {{network}} --ignore
# Forcefully stops and removes the frostbyte container
2023-10-20 00:56:57 +02:00
[private]
clean-podman:
podman container rm -f frostbyte
podman container rm -f frostbyte-debug
# Forcefully removes the frostbyte images
2023-10-20 00:56:57 +02:00
[private]
clean-images:
podman image rm -f fb-server
podman image rm -f fb-server-debug
# Cleans up everything related to the project
clean: clean-podman clean-images
rm -rf client/dist
rm -rf client/node_modules
2023-11-01 15:47:51 +01:00
rm -rf client-solid/dist
rm -rf client-solid/node_modules
rm -rf server/public
rm -rf server/target
@echo "Cleaned up! Make sure to clean up podman volumes and networks."