diff --git a/DOCKER_README.md b/DOCKER_README.md new file mode 100644 index 0000000..eeed71e --- /dev/null +++ b/DOCKER_README.md @@ -0,0 +1,52 @@ +# How to use Docker for this + +You will need the following structure: + +```bash +root/ +├─ evora-server/ +├─ evora-client/ +├─ docker-compose.yml +``` + +The `docker-compose.yml` is a new file that is attached below: + +```yaml +version: '3.8' + +services: + evora-server: + build: + context: ./evora-server + ports: + - "3000:3000" + volumes: + - ./evora-server:/usr/src/app + command: python app.py # Start the Flask app + environment: + - FLASK_RUN_HOST=0.0.0.0 # Bind to all interfaces for external access + - FLASK_ENV=development # Optional: Enables Flask debug mode for development + + evora-client: + build: + context: ./evora-client + ports: + - "3001:3001" + volumes: + - ./evora-client:/usr/src/app + - /usr/src/app/node_modules # Add this to map node_modules correctly + + command: npm start # Start the React app + environment: + - PORT=3001 # Set the port for the React app + depends_on: + - evora-server +``` + +When you have this structure, go to the root directory and use the following command in the console (install Docker first): +`docker compose up --build` +which will build the container and run it. Then you can access the web app at + +`http://127.0.0.1:3001`. + +Note: When you React or Flask files, you do NOT need to rebuild the container. It will be automatically updated without you having to restart anything. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1701a7e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Node.js image +FROM node:14 + +# Set working directory +WORKDIR /usr/src/app + +# Copy package files and install dependencies +COPY package*.json ./ +RUN npm install + +# Copy the rest of the app +COPY . . + +# Expose the port React runs on +EXPOSE 3001 + +# Start the React app +CMD ["npm", "start"] diff --git a/package.json b/package.json index e62d0a8..6dcbe6f 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "cross-env PORT=3001 react-scripts start", + "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", diff --git a/src/apiClient.js b/src/apiClient.js index 7b78f38..ef78022 100644 --- a/src/apiClient.js +++ b/src/apiClient.js @@ -2,7 +2,7 @@ * Contains all functions for api requests to the server. */ // const baseURL = 'http://localhost:3005'; -const baseURL = '/api' +const baseURL = 'http://localhost:3000' // Creates a POST request. export function buildPostPayload(data) {