diff --git a/README.md b/README.md index b734cd05..0b911db2 100644 --- a/README.md +++ b/README.md @@ -73,8 +73,25 @@ cd react ### 2. Environment Setup +This project can be run locally using Node.js or with Docker. + +#### Option 1: Docker (Recommended) + +Using Docker is the recommended way to run the project, as it automatically sets up all the services and databases for you. + +1. **Install Docker Desktop**: Make sure you have Docker Desktop installed and running on your system. +2. **Create `default.json`**: A `default.json` file containing environment variables will be provided to contributors. Place this file in `middlewareNode/config/`. +3. **Build and Run**: From the project root, run the following command: + ```bash + docker-compose -f deploy/dev/docker-compose.yml up --build + ``` +4. **Access the Application**: The application will be available at [http://localhost:8080](http://localhost:8080). + +#### Option 2: Local Node.js Setup + Before running any services, create the local development environment from the **project root directory**: + ```bash ./create_dev_envs.sh ``` diff --git a/chessServer/Dockerfile b/chessServer/Dockerfile index 66db9e60..096e5c74 100644 --- a/chessServer/Dockerfile +++ b/chessServer/Dockerfile @@ -1,13 +1,12 @@ -FROM node +FROM node:18.20.8-alpine WORKDIR /usr/src/app COPY package*.json ./ -RUN npm install -RUN npm ci --only=production +RUN npm install --only=production COPY . . -EXPOSE 3000 -CMD [ "node", "index.js" ] \ No newline at end of file +EXPOSE 3001 +CMD [ "node", "index.js" ] diff --git a/deploy/dev/docker-compose.yml b/deploy/dev/docker-compose.yml index 404c78a0..75f018c6 100644 --- a/deploy/dev/docker-compose.yml +++ b/deploy/dev/docker-compose.yml @@ -4,48 +4,37 @@ services: apache: image: httpd:2.4 ports: - - "80:80" + - "8080:80" volumes: - - ./deploy/dev/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro + - ../dev/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro depends_on: - react-app - - middlewareNode - - chessServer - - stockfishServer + - middlewarenode + - chessserver + - stockfishserver react-app: build: ../../react-ystemandchess container_name: react-app expose: - "3000" - environment: - - REACT_APP_CHESS_SERVER_URL=http://localhost:3001 - - REACT_APP_MIDDLEWARE_URL=http://localhost:8000 - - REACT_APP_STOCKFISH_URL=http://localhost:8080 - middlewareNode: + middlewarenode: build: ../../middlewareNode container_name: middlewarenode expose: - "8000" - environment: - - PORT=8000 + volumes: + - ../../middlewareNode/config/default.json:/app/config/default.json:ro - chessServer: + chessserver: build: ../../chessServer container_name: chessserver expose: - "3001" - environment: - - PORT=3001 - stockfishServer: + stockfishserver: build: ../../stockfishServer container_name: stockfishserver expose: - "9324" - environment: - - PORT=9324 - -# Usage: docker-compose up --build -# Access at: http://localhost \ No newline at end of file diff --git a/middlewareNode/Dockerfile b/middlewareNode/Dockerfile index 137d6f16..e4bd4847 100644 --- a/middlewareNode/Dockerfile +++ b/middlewareNode/Dockerfile @@ -1,13 +1,12 @@ -FROM node +FROM node:18.20.8-alpine WORKDIR /app COPY package*.json ./ -RUN npm install -RUN npm ci --only=production +RUN npm install --only=production COPY . . EXPOSE 8000 -CMD [ "node", "server.js" ] \ No newline at end of file +CMD [ "node", "server.js" ] diff --git a/stockfishServer/Dockerfile b/stockfishServer/Dockerfile index 0a03467f..31fa5409 100644 --- a/stockfishServer/Dockerfile +++ b/stockfishServer/Dockerfile @@ -1,13 +1,14 @@ -FROM node:alpine +FROM node:18.20.8-alpine WORKDIR /usr/src/app COPY package*.json ./ -RUN npm install -RUN npm ci --only=production +RUN npm install --only=production COPY . . -EXPOSE 8080 -CMD [ "node", "index.js" ] +RUN chmod +x /usr/src/app/src/bin/stockfish_11_linux + +EXPOSE 9324 +CMD [ "node", "src/index.js" ]