Setting Up Docker - april1703/SpotiReels GitHub Wiki

Docker Set Up

The SpotiReels application uses lots of different packages, and keeping track of dependencies and what works for each developer's computer is difficult; thus, SpotiReels was made to be run on Docker. This includes having three separate containers for the app, the service server, and the user database. Each container has a defined packages.json file, a dockerfile for setup, and a .env variable for secrets.

How to run SpotiReels

To begin, make sure Docker Compose's engine is running. On windows, this can be checked by pressing the "up" arrow in the bottom right corner (next to system time, wifi, sound, etc.), and looking for the Docker icon, as shown here.

Clicking on the Docker icon should take you to the compose app. If this icon is not there, then open the Docker Compose app as you would any other Windows application (searching in search bar, clicking on app).

1. Setting up SQL

Since the SQL container doesn't require any build, running the SQL container is only one command:

docker-compose up mysql-users

NOTE: Wait for this terminal to finish setting up before you start the backend! The completed process should look similar to the following:

2. Setting up the Backend Server

The service server runs in an Apache container, and thus requires setup of NPM. Luckily, Docker does most of the footwork for us. Start by building the container:

docker-compose build server

Once this is fully built, the container can now be run:

docker-compose up server

You'll know this has worked if you get the following:

3. Setting up the React Development Server (Client)

This service is also in an Apache container and requires some dependencies before it runs. Build the container first:

docker-compose build client

Once this is done, the container can be run:

docker-compose up client

Closing Containers

If you are debugging and need to reset the environment, you must first pull the containers from the Docker engine; if not, your changes will not be reflected. Do this by using "down":

docker-compose down mysql-users
docker-compose down server
docker-compose down client

Once an app is pulled down, it must be rebuilt. Thus, use the previous steps of how to run SpotiReels to recontainerize and run the application.

NOTE: The backend utilizes Nodemon, and the frontend utilizes React scripts, so you shouldn't have to rebuild the containers with every little change! You will know that these are working if, when you make a change to any JS files, the terminal states it is recompiling. Please note THIS ONLY WORKS FOR JAVASCRIPT FILES; if you change a different type of file (ie. .env, .sql, etc.), you must rebuild the container!

Errors

If you encounter any docker errors, please take a screenshot of the error message and DM me the image plus a description of what you were doing beforehand, and I will attempt to help you with your Dockering.