diff --git a/.env.TEMPLATE b/.env.TEMPLATE index c34971f..0758f98 100644 --- a/.env.TEMPLATE +++ b/.env.TEMPLATE @@ -1,9 +1,14 @@ RUST_LOG=debug,actix=warn,diesel_migrations=warn,reqwest=warn,hyper=warn + DATABASE_CONTAINER=weather-db DATABASE_HOST=db -DATABASE_USER= +DATABASE_USER=weather DATABASE_PASSWORD= DATABASE_NAME=weather DATABASE_PORT=5432 -SERVICE_HOST=localhost -SERVICE_PORT=5000 \ No newline at end of file + +SERVICE_HOST=service +SERVICE_PORT=5000 + +UI_PORT=3000 +NODE_ENV=development \ No newline at end of file diff --git a/Makefile b/Makefile index 68822ea..9b0fdc6 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ help: ## This info @cat Makefile | grep -E '^[a-zA-Z\/_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @echo -build: ## Build Docker service container +build: ## Build Docker containers docker compose build -up: ## Start Docker service containers +up: ## Start Docker containers docker compose up -d -down: ## Stop Docker service containers +down: ## Stop Docker containers docker compose down connect: ## Connect to the Weather DB diff --git a/docker-compose.yml b/docker-compose.yml index 7bc202d..98b8426 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: - db:/var/lib/postgresql/data - db_logs:/var/log ports: - - "${DATABASE_PORT}:5432" + - "${DATABASE_PORT:-5432}:5432" networks: - weather-backend restart: unless-stopped @@ -25,7 +25,7 @@ services: env_file: - .env ports: - - "${SERVICE_PORT}:5000" + - "${SERVICE_PORT:-5000}:5000" build: context: service depends_on: @@ -40,9 +40,9 @@ services: env_file: - .env environment: - - NODE_ENV=${NODE_ENV} + - NODE_ENV=${NODE_ENV:-production} ports: - - ${UI_PORT}:3000 + - ${UI_PORT:-3000}:3000 build: context: ui depends_on: diff --git a/service/src/db.rs b/service/src/db.rs index 0f31144..a583f42 100644 --- a/service/src/db.rs +++ b/service/src/db.rs @@ -18,7 +18,8 @@ lazy_static! { let password = env::var("DATABASE_PASSWORD").expect("Database password is not set"); let host = env::var("DATABASE_HOST").expect("Database host is not set"); let name = env::var("DATABASE_NAME").expect("Database name is not set"); - let port = env::var("DATABASE_PORT").expect("Database port is not set"); + // let port = env::var("DATABASE_PORT").expect("Database port is not set"); + let port = 5432; let url = format!("postgres://{}:{}@{}:{}/{}", username, password, host, port, name); let manager = ConnectionManager::::new(url); Pool::builder().test_on_check_out(true).build(manager).expect("Failed to create db pool") diff --git a/ui/.env.TEMPLATE b/ui/.env.TEMPLATE new file mode 100644 index 0000000..b339118 --- /dev/null +++ b/ui/.env.TEMPLATE @@ -0,0 +1,5 @@ +SERVICE_HOST=service +SERVICE_PORT=5000 + +UI_PORT=8080 +NODE_ENV=development \ No newline at end of file diff --git a/ui/Makefile b/ui/Makefile index 73b05c1..9539687 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -9,18 +9,18 @@ help: ## This info @cat Makefile | grep -E '^[a-zA-Z\/_-]+:.*?## .*$$' | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @echo -install: ## Install the dependencies - npm install - build: ## Install the dependencies and build - npm run build + docker compose build -start: ## Start the dev instance - npm install - npm run dev +up: ## Start the dev instance + docker compose up -d + +down: ## Stop the dev instance + docker compose down lint: ## Run the linter npm run lint clean: ## Remove node modules - rm -rf node_modules \ No newline at end of file + docker compose down && \ + docker image rm weather-ui \ No newline at end of file