From 345dc105df60e2ad34e9747561abe5cd11c5bdb6 Mon Sep 17 00:00:00 2001 From: Benjamin Sherriff Date: Sat, 4 May 2024 14:00:54 -0400 Subject: [PATCH] Fixed env stuff --- .gitignore | 2 +- service/{.env.TEMPLATE => .env} | 16 ++++++++-------- service/Makefile | 20 ++++++++++++++++++-- service/rustfmt.toml | 3 +++ service/src/main.rs | 4 +--- ui/{.env.TEMPLATE => .env} | 2 +- 6 files changed, 32 insertions(+), 15 deletions(-) rename service/{.env.TEMPLATE => .env} (53%) create mode 100644 service/rustfmt.toml rename ui/{.env.TEMPLATE => .env} (82%) diff --git a/.gitignore b/.gitignore index 32209be..15b3618 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Common keys/ -.env +.env*.local # Service target/ diff --git a/service/.env.TEMPLATE b/service/.env similarity index 53% rename from service/.env.TEMPLATE rename to service/.env index 743a54d..5016f62 100644 --- a/service/.env.TEMPLATE +++ b/service/.env @@ -1,16 +1,16 @@ -RUST_LOG=warn,service=info +RUST_LOG=warn,service=debug DATABASE_USER=siren -DATABASE_PASSWORD= #Required +DATABASE_PASSWORD= # FILL ME IN DATABASE_NAME=siren DATABASE_HOST=localhost DATABASE_PORT=5432 -KEYS_DIR_PATH= +KEYS_DIR_PATH= # OPTIONAL SESSION_TTL=1440 MINIO_ROOT_USER=siren -MINIO_ROOT_PASSWORD= #Required +MINIO_ROOT_PASSWORD= # FILL ME IN MINIO_HOST=localhost MINIO_PORT=9000 MINIO_PORT_INTERNAL=9001 @@ -20,8 +20,8 @@ REDIS_PORT=6379 SERVICE_HOST=localhost SERVICE_PORT=5000 -DATA_DIR_PATH= +DATA_DIR_PATH= # OPTIONAL -DISCORD_TOKEN= #Required -OPENAI_API_KEY= -OPENAI_API_MODEL=gpt-3.5-turbo \ No newline at end of file +DISCORD_TOKEN= # OPTIONAL +OPENAI_API_KEY= # OPTIONAL +OPENAI_API_MODEL=gpt-3.5-turbo-0125 diff --git a/service/Makefile b/service/Makefile index 4210ff8..61cdc3e 100644 --- a/service/Makefile +++ b/service/Makefile @@ -1,7 +1,11 @@ #!make SHELL := /bin/bash +GIT_HASH ?= $(shell git log --format="%h" -n 1) +export VERSION=$(if $(v),$(v),latest) include .env +-include .env.local +export .PHONY: help build test up down exec clean @@ -16,8 +20,20 @@ up: ## Start the backend containers down: ## Stop the backend containers @docker compose --profile backend down -run: ## Run the app +run: ## Run the project + @echo "Running project..." @cargo run + @echo "Run complete" + +format: ## Format code + @echo "Formatting code..." + @cargo fmt + @echo "Format complete" + +clean: ## Clean the project + @echo "Cleaning project..." + @cargo clean + @echo "Clean complete" docker-up: ## Start the app @docker compose --profile backend --profile siren up -d @@ -28,7 +44,7 @@ docker-down: ## Stop the app docker-build: ## Build the docker image @docker compose build -clean: ## Clean the app +docker-clean: ## Clean the app @docker compose down && \ docker image rm siren-service || \ docker network rm siren_frontend || \ diff --git a/service/rustfmt.toml b/service/rustfmt.toml new file mode 100644 index 0000000..76f62b4 --- /dev/null +++ b/service/rustfmt.toml @@ -0,0 +1,3 @@ +indent_style = "Block" +reorder_imports = false +tab_spaces = 2 \ No newline at end of file diff --git a/service/src/main.rs b/service/src/main.rs index 8210907..f510479 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -16,8 +16,6 @@ use actix_cors::Cors; use actix_web::{HttpServer, App, web}; use crate::bot::handler::Handler; -use dotenv::dotenv; - mod auth; mod dnd; mod bot; @@ -26,7 +24,7 @@ mod users; #[actix_web::main] async fn main() -> std::io::Result<()> { - dotenv().ok(); + dotenv::dotenv().ok(); env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "warn,siren=info")); storage::init().await; match env::var("DATA_DIR_PATH") { diff --git a/ui/.env.TEMPLATE b/ui/.env similarity index 82% rename from ui/.env.TEMPLATE rename to ui/.env index b339118..5af3be1 100644 --- a/ui/.env.TEMPLATE +++ b/ui/.env @@ -1,5 +1,5 @@ SERVICE_HOST=service SERVICE_PORT=5000 -UI_PORT=8080 +UI_PORT=3000 NODE_ENV=development \ No newline at end of file