From f65869fd263bd4c2d9633e118aa5966b9e11d862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Thu, 30 May 2024 15:09:43 +0200 Subject: [PATCH 01/14] wip backend dockerfile --- backend/Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..3ec01fb --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,36 @@ +# Use the official Python image from the Docker Hub +FROM python:3.9.13-slim + +# Set environment variables +ENV PYTHONUNBUFFERED=1 + +# Set the working directory +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + build-essential \ + libpq-dev \ + wget \ + tar \ + && rm -rf /var/lib/apt/lists/* + +# Install Stockfish +RUN wget https://github.com/official-stockfish/Stockfish/releases/latest/download/stockfish-ubuntu-x86-64-vnni512.tar -O /tmp/stockfish.tar && \ + tar -xvf /tmp/stockfish.tar -C /usr/local/bin/ && \ + rm /tmp/stockfish.tar + +# Copy only the requirements file +COPY requirements.txt . + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code +COPY . . + +# Expose the port the app runs on +EXPOSE 5000 + +# Command to run the application +CMD ["python", "server.py"] \ No newline at end of file From 9785b71c161e5c8f1d4befa9e5602a8d1caecdab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Thu, 30 May 2024 18:48:46 +0200 Subject: [PATCH 02/14] backend docker container runs but... Will need to configure the robotic arm to interface with it --- backend/.dockerignore | 8 ++++++++ backend/Dockerfile | 28 +++++++++++++++++++++------- backend/server.py | 5 +++-- backend/start.sh | 4 ++++ 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 backend/.dockerignore create mode 100644 backend/start.sh diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..0a7a659 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,8 @@ +**/__pycache__ +**/*.pyc +**/*.pyo +**/*.pyd +*.git +.dockerignore +Dockerfile* +*.md diff --git a/backend/Dockerfile b/backend/Dockerfile index 3ec01fb..0dcb661 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -13,12 +13,22 @@ RUN apt-get update && apt-get install -y \ libpq-dev \ wget \ tar \ + git \ + g++ \ + make \ && rm -rf /var/lib/apt/lists/* -# Install Stockfish -RUN wget https://github.com/official-stockfish/Stockfish/releases/latest/download/stockfish-ubuntu-x86-64-vnni512.tar -O /tmp/stockfish.tar && \ - tar -xvf /tmp/stockfish.tar -C /usr/local/bin/ && \ - rm /tmp/stockfish.tar +# Check the architecture +RUN uname -m + +# Clone Stockfish and compile it +RUN git clone https://github.com/official-stockfish/Stockfish.git && \ + cd Stockfish/src && \ + make build ARCH=armv8 && \ + cp stockfish /usr/local/bin/ && \ + chmod +x /usr/local/bin/stockfish && \ + cd ../.. && \ + rm -rf Stockfish # Copy only the requirements file COPY requirements.txt . @@ -26,11 +36,15 @@ COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt -# Copy the rest of the application code +# Copy the start script and the rest of the application code +COPY start.sh . COPY . . +# Give execute permissions to the start script +RUN chmod +x start.sh + # Expose the port the app runs on EXPOSE 5000 -# Command to run the application -CMD ["python", "server.py"] \ No newline at end of file +# Command to run the start script +CMD ["./start.sh"] diff --git a/backend/server.py b/backend/server.py index 2baa161..214f6d6 100644 --- a/backend/server.py +++ b/backend/server.py @@ -1,7 +1,6 @@ from argparse import ArgumentParser from flask import Flask from flask_socketio import SocketIO -from config import STOCKFISH_PATH from chessLogic.chessLogic import ChessLogic from certaboHelper.certabo import Certabo from certaboHelper.initCertabo import InitializeCertabo @@ -18,7 +17,9 @@ if platform.system() == 'Windows': pStockfish ="/chessLogic/windowsStockfish/stockfish-windows.exe" elif platform.system() == 'Darwin': #Darwin for MacOS - pStockfish = STOCKFISH_PATH + pStockfish = "/opt/homebrew/bin/stockfish" +else: #Default to Linux + pStockfish ="/usr/local/bin/stockfish" chess_logic = ChessLogic(pStockfish) diff --git a/backend/start.sh b/backend/start.sh new file mode 100644 index 0000000..3599b7c --- /dev/null +++ b/backend/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +echo "Starting Python application..." +python server.py From d3e1d82d8e8f1f91a3edc868fdb75ee46c5dd382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Thu, 30 May 2024 20:21:22 +0200 Subject: [PATCH 03/14] backend docker: add postgresql to the same image --- backend/Dockerfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 0dcb661..4bc7de0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,6 +3,9 @@ FROM python:3.9.13-slim # Set environment variables ENV PYTHONUNBUFFERED=1 +ENV POSTGRES_USER=username +ENV POSTGRES_PASSWORD=password +ENV POSTGRES_DB=databasename # Set the working directory WORKDIR /app @@ -11,6 +14,7 @@ WORKDIR /app RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ + postgresql \ wget \ tar \ git \ @@ -30,6 +34,17 @@ RUN git clone https://github.com/official-stockfish/Stockfish.git && \ cd ../.. && \ rm -rf Stockfish +# Start PostgreSQL service and setup database +USER postgres +RUN service postgresql start && \ + psql -c "CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER ROLE $POSTGRES_USER CREATEDB;" + +RUN service postgresql start && \ + psql -c "CREATE DATABASE $POSTGRES_DB;" && \ + psql -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;" + +USER root + # Copy only the requirements file COPY requirements.txt . @@ -47,4 +62,4 @@ RUN chmod +x start.sh EXPOSE 5000 # Command to run the start script -CMD ["./start.sh"] +CMD ["./start.sh"] \ No newline at end of file From 21f6ce1cf0da0f03da7615198a1e5b4c20f7b57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Thu, 30 May 2024 20:36:20 +0200 Subject: [PATCH 04/14] add certabo chess-board driver... needs to be tested --- backend/Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 4bc7de0..8124f96 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -16,14 +16,22 @@ RUN apt-get update && apt-get install -y \ libpq-dev \ postgresql \ wget \ + unzip \ tar \ git \ g++ \ make \ && rm -rf /var/lib/apt/lists/* -# Check the architecture -RUN uname -m +# Download the Certabo software +RUN wget https://www.certabo.com/wp-content/uploads/SOFTWARE/Release/Ubuntu/Certabo_Tabutronic_Ubuntu_4.5.zip + +# Extract the Certabo software +RUN unzip /app/Certabo_Tabutronic_Ubuntu_4.5.zip -d /app + +# Install the Certabo software +RUN dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb || true +RUN apt-get install -f # Clone Stockfish and compile it RUN git clone https://github.com/official-stockfish/Stockfish.git && \ From 24749748b65d3bad6d880829437460c002257705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 07:51:28 +0200 Subject: [PATCH 05/14] Switch to arm-compatible docker image --- backend/Dockerfile | 10 ++++++++-- backend/start.sh | 12 +++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 8124f96..f11931a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,11 @@ -# Use the official Python image from the Docker Hub -FROM python:3.9.13-slim +# Select the base image according to the architecture +# Uncomment the line that corresponds to the architecture you are using + +# For x86 architecture, use the following base image: +# FROM python:3.9.13-slim + +# For arm architecture (like Raspberry Pi or macOS M1 chip), use the following base image: +FROM python:3.9.13-slim-buster # Set environment variables ENV PYTHONUNBUFFERED=1 diff --git a/backend/start.sh b/backend/start.sh index 3599b7c..3f51a8d 100644 --- a/backend/start.sh +++ b/backend/start.sh @@ -1,4 +1,14 @@ #!/bin/bash -echo "Starting Python application..." +DEVICE_PATH="/dev/ttyUSB0" +if [ -c "$DEVICE_PATH" ] +then + echo -e "\n\n\tDevice $DEVICE_PATH is accessible.\n\n" +else + echo -e "\nError: Device $DEVICE_PATH is not accessible.\n\nPlease check the device path or connection.\n\nMaybe you forgot to mount the device?\n\nExample docker run command: \n\tdocker run --device=/dev/ttyUSB0:/dev/ttyUSB0 -p 5000:5000 chess-backend\n\n" + exit 1 +fi + +# Start the Python application +echo -e "\n\n\tStarting Python application...\n\n" python server.py From 796c614ca1d0a7b2999f46fe2112cb1e0fea7e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 10:52:58 +0200 Subject: [PATCH 06/14] Frontend dockerized --- frontend/Dockerfile | 13 +++++++++++++ frontend/package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 frontend/Dockerfile diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..cbe13be --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,13 @@ +# Build stage +FROM node:lts-alpine3.20 AS build +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# Run stage +FROM nginx:alpine +COPY --from=build /app/build /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json index bdf7f01..aac54bf 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -20,7 +20,7 @@ "react-router-dom": "^6.14.0", "react-scripts": "5.0.1", "socket.io-client": "^4.7.1", - "typescript": "^5.1.6", + "typescript": "^4.9.5", "web-vitals": "^2.1.4", "xtypejs": "^0.7.1" }, From 87606d81c01d1a7f9ea15b637595e7c1bb710b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 12:16:51 +0200 Subject: [PATCH 07/14] try using precompiled binary --- backend/Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index f11931a..0decbc5 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -40,13 +40,12 @@ RUN dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb RUN apt-get install -f # Clone Stockfish and compile it -RUN git clone https://github.com/official-stockfish/Stockfish.git && \ - cd Stockfish/src && \ - make build ARCH=armv8 && \ - cp stockfish /usr/local/bin/ && \ +# Download and extract the precompiled Stockfish binary +RUN wget https://github.com/official-stockfish/Stockfish/releases/download/stockfish-dev-20240530-54e74919/stockfish-android-armv8.tar -O stockfish.tar && \ + tar -xf stockfish.tar && \ + mv stockfish /usr/local/bin/ && \ chmod +x /usr/local/bin/stockfish && \ - cd ../.. && \ - rm -rf Stockfish + rm stockfish.tar # Start PostgreSQL service and setup database USER postgres From 911373e5423f905e01db87a3ae49ad6d38ca0684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 12:21:15 +0200 Subject: [PATCH 08/14] try fix python requirements error when building docker container on the pi itself --- backend/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 0decbc5..e3f0b22 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -61,6 +61,9 @@ USER root # Copy only the requirements file COPY requirements.txt . +# Install cmake separately +RUN pip install cmake + # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt From 0f10ab3a917731e7bba575c63934a68b7a7bfede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 12:24:14 +0200 Subject: [PATCH 09/14] install cmake via apt-get instead --- backend/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index e3f0b22..a289e95 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -27,6 +27,7 @@ RUN apt-get update && apt-get install -y \ git \ g++ \ make \ + cmake \ && rm -rf /var/lib/apt/lists/* # Download the Certabo software @@ -61,9 +62,6 @@ USER root # Copy only the requirements file COPY requirements.txt . -# Install cmake separately -RUN pip install cmake - # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt From 8f93de3d1afa8052cb21d9785012bd6ac823ace8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 14:49:02 +0200 Subject: [PATCH 10/14] aaaa --- backend/Dockerfile | 56 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index a289e95..0e2384f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,11 +1,5 @@ -# Select the base image according to the architecture -# Uncomment the line that corresponds to the architecture you are using - -# For x86 architecture, use the following base image: -# FROM python:3.9.13-slim - -# For arm architecture (like Raspberry Pi or macOS M1 chip), use the following base image: -FROM python:3.9.13-slim-buster +# Use the official Python base image for arm64 architecture +FROM arm64v8/python:3.9.13-slim-buster # Set environment variables ENV PYTHONUNBUFFERED=1 @@ -23,57 +17,61 @@ RUN apt-get update && apt-get install -y \ postgresql \ wget \ unzip \ - tar \ git \ g++ \ make \ cmake \ && rm -rf /var/lib/apt/lists/* -# Download the Certabo software -RUN wget https://www.certabo.com/wp-content/uploads/SOFTWARE/Release/Ubuntu/Certabo_Tabutronic_Ubuntu_4.5.zip +# Update CMake to the latest version +RUN apt-get update && apt-get install -y cmake -# Extract the Certabo software -RUN unzip /app/Certabo_Tabutronic_Ubuntu_4.5.zip -d /app +# Upgrade pip to the latest version +RUN /usr/local/bin/python -m pip install --upgrade pip -# Install the Certabo software -RUN dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb || true -RUN apt-get install -f +# Download and install the Certabo software +RUN wget -O /tmp/Certabo_Tabutronic_Ubuntu_4.5.zip https://www.certabo.com/wp-content/uploads/SOFTWARE/Release/Ubuntu/Certabo_Tabutronic_Ubuntu_4.5.zip && \ + unzip /tmp/Certabo_Tabutronic_Ubuntu_4.5.zip -d /app && \ + dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb || true && \ + apt-get install -f # Clone Stockfish and compile it -# Download and extract the precompiled Stockfish binary -RUN wget https://github.com/official-stockfish/Stockfish/releases/download/stockfish-dev-20240530-54e74919/stockfish-android-armv8.tar -O stockfish.tar && \ - tar -xf stockfish.tar && \ - mv stockfish /usr/local/bin/ && \ +RUN git clone https://github.com/official-stockfish/Stockfish.git /app/Stockfish && \ + cd /app/Stockfish/src && \ + make build ARCH=armv8 && \ + cp stockfish /usr/local/bin/ && \ chmod +x /usr/local/bin/stockfish && \ - rm stockfish.tar + cd /app && \ + rm -rf /app/Stockfish # Start PostgreSQL service and setup database USER postgres RUN service postgresql start && \ - psql -c "CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER ROLE $POSTGRES_USER CREATEDB;" + psql -c "CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER ROLE $POSTGRES_USER CREATEDB;" && \ + service postgresql stop RUN service postgresql start && \ psql -c "CREATE DATABASE $POSTGRES_DB;" && \ - psql -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;" + psql -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;" && \ + service postgresql stop USER root # Copy only the requirements file -COPY requirements.txt . +COPY requirements.txt /app/ # Install Python dependencies -RUN pip install --no-cache-dir -r requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt # Copy the start script and the rest of the application code -COPY start.sh . -COPY . . +COPY start.sh /app/ +COPY . /app/ # Give execute permissions to the start script -RUN chmod +x start.sh +RUN chmod +x /app/start.sh # Expose the port the app runs on EXPOSE 5000 # Command to run the start script -CMD ["./start.sh"] \ No newline at end of file +CMD ["/app/start.sh"] From 85093c7dbbd5fa3da70c9f96fead5a643821f05f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 14:50:38 +0200 Subject: [PATCH 11/14] b --- backend/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 0e2384f..43b7f5e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -11,7 +11,8 @@ ENV POSTGRES_DB=databasename WORKDIR /app # Install system dependencies -RUN apt-get update && apt-get install -y \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ build-essential \ libpq-dev \ postgresql \ @@ -23,7 +24,7 @@ RUN apt-get update && apt-get install -y \ cmake \ && rm -rf /var/lib/apt/lists/* -# Update CMake to the latest version +# Update CMake to the latest version if necessary RUN apt-get update && apt-get install -y cmake # Upgrade pip to the latest version From ca48cfdfd588727f93431cf9d6fafabb03064c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 14:52:02 +0200 Subject: [PATCH 12/14] c --- backend/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 43b7f5e..740d07f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -11,8 +11,9 @@ ENV POSTGRES_DB=databasename WORKDIR /app # Install system dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ +RUN apt-get update + +RUN apt-get install -y --no-install-recommends \ build-essential \ libpq-dev \ postgresql \ From 9801b4868eeabd4390e1e62f35a25d20af83fdeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Fri, 31 May 2024 14:53:51 +0200 Subject: [PATCH 13/14] revert --- backend/Dockerfile | 52 ++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 740d07f..887fea4 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,5 @@ -# Use the official Python base image for arm64 architecture -FROM arm64v8/python:3.9.13-slim-buster +# For x86 architecture, use the following base image: +FROM python:3.9.13-slim # Set environment variables ENV PYTHONUNBUFFERED=1 @@ -11,69 +11,63 @@ ENV POSTGRES_DB=databasename WORKDIR /app # Install system dependencies -RUN apt-get update - -RUN apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ postgresql \ wget \ unzip \ + tar \ git \ g++ \ make \ - cmake \ && rm -rf /var/lib/apt/lists/* -# Update CMake to the latest version if necessary -RUN apt-get update && apt-get install -y cmake +# Download the Certabo software +RUN wget https://www.certabo.com/wp-content/uploads/SOFTWARE/Release/Ubuntu/Certabo_Tabutronic_Ubuntu_4.5.zip -# Upgrade pip to the latest version -RUN /usr/local/bin/python -m pip install --upgrade pip +# Extract the Certabo software +RUN unzip /app/Certabo_Tabutronic_Ubuntu_4.5.zip -d /app -# Download and install the Certabo software -RUN wget -O /tmp/Certabo_Tabutronic_Ubuntu_4.5.zip https://www.certabo.com/wp-content/uploads/SOFTWARE/Release/Ubuntu/Certabo_Tabutronic_Ubuntu_4.5.zip && \ - unzip /tmp/Certabo_Tabutronic_Ubuntu_4.5.zip -d /app && \ - dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb || true && \ - apt-get install -f +# Install the Certabo software +RUN dpkg -i /app/Certabo_Tabutronic_Ubuntu_4.5/Certabo_Tabutronic_Ubuntu_4.5.deb || true +RUN apt-get install -f # Clone Stockfish and compile it -RUN git clone https://github.com/official-stockfish/Stockfish.git /app/Stockfish && \ - cd /app/Stockfish/src && \ +RUN git clone https://github.com/official-stockfish/Stockfish.git && \ + cd Stockfish/src && \ make build ARCH=armv8 && \ cp stockfish /usr/local/bin/ && \ chmod +x /usr/local/bin/stockfish && \ - cd /app && \ - rm -rf /app/Stockfish + cd ../.. && \ + rm -rf Stockfish # Start PostgreSQL service and setup database USER postgres RUN service postgresql start && \ - psql -c "CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER ROLE $POSTGRES_USER CREATEDB;" && \ - service postgresql stop + psql -c "CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD'; ALTER ROLE $POSTGRES_USER CREATEDB;" RUN service postgresql start && \ psql -c "CREATE DATABASE $POSTGRES_DB;" && \ - psql -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;" && \ - service postgresql stop + psql -c "GRANT ALL PRIVILEGES ON DATABASE $POSTGRES_DB TO $POSTGRES_USER;" USER root # Copy only the requirements file -COPY requirements.txt /app/ +COPY requirements.txt . # Install Python dependencies -RUN pip install --no-cache-dir -r /app/requirements.txt +RUN pip install --no-cache-dir -r requirements.txt # Copy the start script and the rest of the application code -COPY start.sh /app/ -COPY . /app/ +COPY start.sh . +COPY . . # Give execute permissions to the start script -RUN chmod +x /app/start.sh +RUN chmod +x start.sh # Expose the port the app runs on EXPOSE 5000 # Command to run the start script -CMD ["/app/start.sh"] +CMD ["./start.sh"] \ No newline at end of file From b03b1d36f1fd472f38f24d9697d4c4ac5083d79a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20Sj=C3=B8en?= Date: Mon, 3 Jun 2024 19:24:36 +0200 Subject: [PATCH 14/14] initial work in progress docker-compose --- docker-compose.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..0f3cc60 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' +services: + stockfish: + image: tchorwat/stockfish + ports: + - "23249:23249" + + postgres: + image: postgres:14 + environment: + POSTGRES_PASSWORD: password + ports: + - "5432:5432" + + backend: + build: + context: ./backend + dockerfile: Dockerfile + ports: + - "5000:5000" + depends_on: + - postgres + - stockfish + + frontend: + build: + context: ./frontend + dockerfile: Dockerfile + ports: + - "3000:3000" + depends_on: + - backend \ No newline at end of file