Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
9 changes: 4 additions & 5 deletions chessServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
EXPOSE 3001
CMD [ "node", "index.js" ]
31 changes: 10 additions & 21 deletions deploy/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 3 additions & 4 deletions middlewareNode/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
CMD [ "node", "server.js" ]
11 changes: 6 additions & 5 deletions stockfishServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
Loading