This guide provides instructions for setting up the web server on a fresh Ubuntu server. It covers the installation of Docker and Docker Compose. The installation of Node.js and other dependencies such as npm packages are handled by Docker, as specified in the Dockerfiles for both the frontend and backend. For example, both Dockerfiles use the node:16
image as a base, ensuring that Node.js is available without requiring a separate installation on the host system. Additionally, dependencies are installed within the containers using RUN npm install
, eliminating the need for Node.js and npm on the Ubuntu server outside of Docker. This approach focuses on Docker as the primary requirement for running DojoDraw.
Note
Please note that this local setup utilises a connection URI for MongoDB Atlas, specified within the environment variables to enhance security. Due to the firewall settings on the Robert Gordon University (RGU) network, this local setup might not work as expected when connected to the RGU network. For convenience and to ensure accessibility, a live version of this application is hosted on the live link below. This ensures that you can evaluate and interact with the application without facing connectivity issues imposed by network restrictions.
๐ DojoDraw Live link (hosted on Netlify & Google Cloud)
- A fresh Ubuntu server
- Root or sudo access
You can automatically download and run the setup script using the following command. This command will download the setup.sh
script, make it executable, and then run it, performing all necessary setup steps.
curl -o setup.sh https://raw.githubusercontent.com/FrancescoCoding/DojoDraw/main/setup.sh?token=<get-from-owner> && chmod +x setup.sh && sudo ./setup.sh
After completing the setup steps, the web server should be running. You can verify its status by accessing the server's IP address on the configured ports.
With the current setup, ports so far are:
- http://localhost:5173/ Frontend
- http://localhost:3000/ Backend
If the automatic setup encounters problems, switching to the manual instructions allows for detailed troubleshooting of each step. This method helps pinpoint and resolve issues more effectively.
Ensuring the package lists and installed packages are up to date by running the following commands in the Ubuntu terminal.
sudo apt-get update
sudo apt-get upgrade -y
Install Docker to manage the containers.
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install -y docker-ce
Install Docker Compose to manage multi-container Docker applications.
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Clone the project repository from GitHub.
git clone https://github.com/FrancescoCoding/DojoDraw
cd coursework-FrancescoCoding
Rename the .env.example
file to .env
in thebackend
directory.
To maintain security, the .env
file is not included in the repository.
The only thing missing is the MONGO_URI , which is the connection URI for MongoDB Atlas.
This will need to be obtained by the project owner and added to the .env
file.
You can also create a different database and add the connection URI to the .env
file. This will allow you to run the application with your own database, as all the necessary collections will be created automatically.
SERVER_PORT=8080
MONGO_URI=mongodb+srv://francesco:<PASSWORD>@cluster0.zcq46lg.mongodb.net/DojoDraw
NODE_ENV=development
Use Docker Compose to build and start the web server.
docker-compose up -d