diff --git a/MAKE_COMMANDS.md b/MAKE_COMMANDS.md new file mode 100644 index 0000000..c209fe7 --- /dev/null +++ b/MAKE_COMMANDS.md @@ -0,0 +1,130 @@ +# Docker compose commands Documentation + +## Overview +This doc is designed for managing the Docker-based project. It includes various commands for building, running, and maintaining both production and development environments. Below is a detailed description of each command available in the Makefile. + +## Commands + +### Production Commands + +- **build**: Builds Docker images for both production environment. +```sh +make build +``` + +- **start**: Starts a specific container or all containers. Specify the container with the `c` variable. +```sh +make start c=container_name +``` + +- **restart**: Restart a specific container or all containers. Specify the container with the `c` variable. +```sh +make restart c=container_name +``` + +- **kill**: Stops a specific container or all containers. Specify the container with the `c` variable. +```sh +make kill c=container_name +``` + +- **dbrestore:** Restores the database from a backup file. +```sh +make dbrestore +``` + +- **update-migrations**: Creates new migration files based on changes in models. +```sh +make update-migrations +``` + +- **migrate**: Runs database migrations, with the `auth` app being migrated first. +```sh +make migrate +``` + +- **createsuperuser**: Create an admin user. +```sh +make createsuperuser +``` + +- **qgisfeed-shell:** Opens a shell in the `qgisfeed` container. +```sh +make qgisfeed-shell +``` + +- **qgisfeed-logs:** Tails the requests logs in the `qgisfeed` container. +```sh +make qgisfeed-logs +``` + +- **nginx-shell:** Opens a shell in the `nginx` container. +```sh +make nginx-shell +``` + +- **nginx-logs:** Tails the requests logs in the `nginx` container. +```sh +make nginx-logs +``` + +- **logs:** Tails logs for a specific container or all containers. Specify the container with the `c` variable. +```sh +make logs c=container_name +``` + +- **shell:** Opens a shell in a specific container. Specify the container with the `c` variable. +```sh +make shell c=container_name +``` + +- **exec:** Executes a specific Docker command. Specify the command with the `c` variable. +```sh +make exec c="command" +``` + +### Development Commands + +- **dev-build:** Builds Docker images for the development environment. +```sh +make dev-build +``` + +- **dev-start:** Start all containers in development environment. +```sh +make dev-start +``` + +- **dev-logs:** Show the logs in development mode. +```sh +make dev-logs +``` + +- **dev-update-migrations**: Creates new migration files based on changes in models. +```sh +make dev-update-migrations +``` + +- **dev-migrate**: Runs database migrations, with the `auth` app being migrated first. +```sh +make dev-migrate +``` + +- **dev-dbseed**: Seed db with JSON data from /fixtures/*.json. +```sh +make dev-dbseed +``` + +- **dev-createsuperuser**: Create an admin user. +```sh +make dev-createsuperuser +``` + +- **dev-runtests**: Running tests in development mode. +```sh +make dev-runtests +``` + +- **dev-stop**: Stopping the development server. +```sh +make dev-stop +``` \ No newline at end of file diff --git a/Makefile b/Makefile index 9e1e1fd..199b458 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ dev-logs: @echo "------------------------------------------------------------------" @docker logs -f $(CONTAINER_NAME) -dev-updatemigrations: +dev-update-migrations: @echo @echo "------------------------------------------------------------------" @echo "Running makemigrations in development mode" @@ -84,9 +84,23 @@ build: start: @echo @echo "------------------------------------------------------------------" - @echo "Running in production mode" + @echo "Starting all or specific container(s) in production mode." + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml up -d $(c) + +restart: + @echo + @echo "------------------------------------------------------------------" + @echo "Restarting all or specific container(s) in production mode." + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml up -d $(c) + +kill: + @echo + @echo "------------------------------------------------------------------" + @echo "Killing all or a specific container(s) in production mode" @echo "------------------------------------------------------------------" - @docker compose -f docker-compose-production-ssl.yml up -d + @docker compose -f docker-compose-production-ssl.yml kill $(c) dbrestore: @echo @@ -135,9 +149,52 @@ collectstatic: @echo "------------------------------------------------------------------" @docker compose -f docker-compose-production-ssl.yml exec $(CONTAINER_NAME) python qgisfeedproject/manage.py collectstatic --noinput -stop: + +qgisfeed-shell: + @echo + @echo "------------------------------------------------------------------" + @echo "Shelling into the qgisfeed container" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml exec qgisfeed bash + +qgisfeed-logs: + @echo + @echo "------------------------------------------------------------------" + @echo "Show the qgisfeed container logs" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml logs -f qgisfeed + +nginx-shell: + @echo + @echo "------------------------------------------------------------------" + @echo "Shelling into the nginx container" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml exec nginx bash + +nginx-logs: + @echo + @echo "------------------------------------------------------------------" + @echo "Show the nginx container logs" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml logs -f nginx + +logs: + @echo + @echo "------------------------------------------------------------------" + @echo "Tailing all logs or a specific container" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml logs -f $(c) + +shell: + @echo + @echo "------------------------------------------------------------------" + @echo "Shelling into a specific container" + @echo "------------------------------------------------------------------" + @docker compose -f docker-compose-production-ssl.yml exec $(c) bash + +exec: @echo @echo "------------------------------------------------------------------" - @echo "Stop the production server" + @echo "Execute a specific docker command" @echo "------------------------------------------------------------------" - @docker compose -f docker-compose-production-ssl.yml down + @docker compose -f docker-compose-production-ssl.yml $(c) \ No newline at end of file diff --git a/README.md b/README.md index fb743ab..293100b 100644 --- a/README.md +++ b/README.md @@ -330,8 +330,8 @@ Now check if your browser is showing the site opening with no SSL errors: https: ``` ssh feed.qgis.org cd /home/web/qgis-feed -docker-compose -f docker-compose-production-ssl.yml up certbot -docker-compose -f docker-compose-production-ssl.yml restart nginx +make start c=certbot +make restart c=nginx ``` Now check if your browser is showing the site opening with no SSL errors: https://feed.qgis.org