Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update makefile #84

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions MAKE_COMMANDS.md
Original file line number Diff line number Diff line change
@@ -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
```
69 changes: 63 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading