-
Notifications
You must be signed in to change notification settings - Fork 1
Docker
Docker is a tool that makes running multiple apps at once scalable and mess-free. Because we're running multiple applications in this website (Flask backend, React frontend, database...), and CSESoc's internal servers already use Docker to host websites, we have decided to use Docker too. In Docker-speak, these separate apps are called containers.
For the most part, as a member of subcom, you wouldn't have to worry about Docker, but if you encounter any issues or want to know more about Docker and this project's internals, we hope this guide is helpful!
There are a couple of files throughout the project that are relevant to Docker. Below is a table of these files and what they do:
File name | Description |
---|---|
.docker-compose.yml |
File containing all the details for a specific container (e.g. what port the Flask app will be running on, what order the apps need to be built in). |
.docker-compose.dev.yml |
Same as above, except for the development environment (i.e. when we're writing code). |
{folder}/Dockerfile |
File containing all commands and instructions that need to be executed in order for a specific app to run (e.g. backend/Dockerfile includes installing packages from pip ). |
There are a total of 5 containers in the project:
-
flask_backend
: the Flask backend app, which acts as the "glue" between the user-facing frontend and the database itself. -
pg_database
: the Postgres database, where all our user information is stored. -
pg_database_testing
: an exact copy of the Postgres database, except used for internal purposes. -
react_frontend
: the React frontend, which has all the code for the actual site itself. -
redis_cache
: a Redis database for storing verification codes.
There is a Makefile
in the root folder of this repository which contains shorthands for more complicated Docker commands. These commands will need to be executed while Docker Desktop is running, otherwise you will get an error similar to docker-compose is not found
. Below is a table of these commands:
Command | Description |
---|---|
make build-dev |
Builds all containers from scratch. |
make dev |
Runs all containers, given they've already been built (e.g. you want to reopen apps after they've been closed). |
make destroy-dev |
Destroys all existing containers. |
make stop |
Stops all containers from running. |
make test-backend |
Runs all backend tests. |
Whenever you install a new package (using pipenv
or yarn
), you will need to run make destroy-dev
, then make build-dev
again.