From c8e8a85dbcc8c5206e5a48c4d5c5501ecdeda623 Mon Sep 17 00:00:00 2001 From: vinitparekh17 Date: Thu, 17 Oct 2024 14:28:14 +0530 Subject: [PATCH] fix: docker network issue for mac --- .env.example | 8 ++++++++ README.md | 40 ++++++++++++++++++++++++++++++++++++---- docker-compose.yml | 4 ++-- main.go | 2 ++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..513ebe4 --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +DICEDB_ADDR=localhost:7379 +DICEDB_USERNAME=dice +DICEDB_PASSWORD= +SERVER_PORT=:8080 +IS_TEST_ENVIRONMENT=false +REQUEST_LIMIT_PER_MIN=1000 +REQUEST_WINDOW_SEC=60 +ALLOWED_ORIGINS=http://localhost:3000 \ No newline at end of file diff --git a/README.md b/README.md index 3f3f250..bf8f21b 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,47 @@ $ sudo su $ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /bin v1.60.1 ``` -Steps to clone and run: +### Steps to clone and run: ```sh $ git clone https://github.com/dicedb/playground-mono $ cd playground-mono +$ cp .env.sample .env $ go run main.go ``` -### Using Docker +### Running the Project Using Docker -```sh +#### 1. Clone the repository: + +```bash +git clone https://github.com/dicedb/playground-mono +``` + +#### 2. Navigate to the project directory: + +```bash +cd playground-mono +``` + +#### 3. Copy the sample environment file: + +```bash +cp .env.sample .env +``` +This creates the `.env` file, which stores your environment variables. Make sure to update any necessary values inside this file before running the server. + +#### 4. Start the application using Docker Compose: + +```bash docker compose up -d -``` \ No newline at end of file +``` +This command will pull any necessary Docker images, build the containers, and run them in detached mode (`-d`). + +#### 5. Verify the server is running: + +Open your browser and go to: + +```bash +http://localhost:8000/health +``` +This endpoint should return a status indicating that the server is up and running. \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 02c34b7..2b00215 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: dicedb: image: dicedb/dicedb:latest ports: - - "7379" + - "7379:7379" healthcheck: test: ["CMD", "PING"] interval: 10s @@ -19,7 +19,7 @@ services: depends_on: - dicedb environment: - - DICEDB_ADDR=dicedb:7379 + - DICEDB_ADDR=localhost:7379 - DICEDB_USERNAME=${DICEDB_USERNAME} - DICEDB_PASSWORD=${DICEDB_PASSWORD} networks: diff --git a/main.go b/main.go index 32134a0..6fd164d 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "server/config" "server/internal/db" "server/internal/server" + + _ "github.com/joho/godotenv/autoload" ) func main() {