From 277d25a820a1e21220db16252a0a26a0a3edfa741c015a8a67564e42cb7650aa Mon Sep 17 00:00:00 2001 From: raven <7156279+RavenX8@users.noreply.github.com> Date: Sun, 15 Dec 2024 01:50:55 -0500 Subject: [PATCH] - add: docker-compose.yml to run the services - add: .env.example for the config for docker --- .env.example | 21 ++++++++++ docker-compose.yml | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100755 .env.example create mode 100755 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100755 index 0000000..f53c713 --- /dev/null +++ b/.env.example @@ -0,0 +1,21 @@ +LOG_LEVEL=info +REDIS_URL=redis://:super_safe_password@127.0.0.1:6379/0 +LISTEN_ADDR=0.0.0.0 +CONSUL_URL=http://consul:8500 +POSTGRES_USER=osirose +POSTGRES_PASSWORD=super_safe_postgres_password +POSTGRES_DB=osirose + +# Define service addresses for consul. +# This will set the service address in consul to what ever is placed here. +# This can be a IP address or the container name in docker +AUTH_SERVICE_ADDR=auth-service +API_SERVICE_ADDR=api-service +CHARACTER_SERVICE_ADDR=character-service +DATABASE_SERVICE_ADDR=database-service +PACKET_SERVICE_ADDR=packet-service +WORLD_SERVICE_ADDR=world-service + +#_SERVICE_PORT= # Replace Service name with the service and port with the port you want to run it on. Ex. AUTH_SERVICE_PORT=30000 +#JWT_SECRET=safe_jwt_secret # This is only used for auth-service and is required. +#HEALTH_CHECK_PORT=8080 # This will change the health check port for the services \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..17e9c87 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,98 @@ +services: + auth-service: + build: + context: ./ + dockerfile: ./auth-service/Dockerfile + ports: + - "50051:50051" + env_file: + - ./auth-service/.env + - .env + environment: + - HEALTH_CHECK_PORT=8080 + depends_on: + - database-service + - consul + + api-service: + build: + context: ./ + dockerfile: ./api-service/Dockerfile + ports: + - "8080:8080" + env_file: + - ./api-service/.env + - .env + depends_on: + - auth-service + - consul + + database-service: + build: + context: ./ + dockerfile: ./database-service/Dockerfile + ports: + - "50052:50052" + env_file: + - ./database-service/.env + - .env + depends_on: + - db + - consul + + character-service: + build: + context: ./ + dockerfile: ./character-service/Dockerfile + ports: + - "50053:50053" + env_file: + - ./character-service/.env + - .env + depends_on: + - auth-service + - consul + + world-service: + build: + context: ./ + dockerfile: ./world-service/Dockerfile + ports: + - "50054:50054" + env_file: + - ./world-service/.env + - .env + depends_on: + - auth-service + - consul + + packet-service: + build: + context: ./ + dockerfile: ./packet-service/Dockerfile + ports: + - "4000:4000" + env_file: + - ./packet-service/.env + - .env + depends_on: + - auth-service + - consul + + db: + image: postgres:17 + env_file: + - .env + ports: + - "5432:5432" + volumes: + - db_data:/var/lib/postgresql/data + + consul: + image: consul:1.15.4 + command: agent -dev -client=0.0.0.0 + ports: + - "8500:8500" + +volumes: + db_data: \ No newline at end of file