Official documentation for the DjangoForge project.
[!TIP]
Before using the Docker implementation, it’s recommended to utilize Django’s development server for debugging purposes during the initial stages of development.
[!WARNING]
Ensure you update the image name inside the docker-compose.prod.yml with the lowercase name of the repository
[!NOTE]
This guide uses generic terms. The steps may differ slightly depending on the IaaS provider you choose.
To establish a secure connection between your server and GitHub Actions, you need to create and configure SSH keys:
ssh-keygen -t ed25519 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
PRIVATE_KEY
, and paste the private key contents.ssh root@your_server_ip
~/.ssh/authorized_keys
file:
echo "your_public_key" >> ~/.ssh/authorized_keys
[!TIP]
Usenano ~/.ssh/authorized_keys
to edit and verify the key is correctly added.
authorized_keys
file.Per creare il Personal Access Token (PAT) per il secret GHCR_TOKEN
e configurare correttamente tutti gli altri valori, puoi seguire le istruzioni dettagliate che possiamo includere nella documentazione.
Ecco come procedere e come documentarlo:
To deploy the project, you need to set up the necessary secrets in your GitHub repository. Below are step-by-step instructions for obtaining each value:
GHCR_TOKEN
The GitHub Container Registry requires a PAT to authenticate and push Docker images. Follow these steps:
write:packages
(required for pushing Docker images to GHCR).read:packages
(to pull images, if needed).delete:packages
(optional, for cleaning up images).GHCR Token
) and click “Generate token”.GHCR_TOKEN
and paste the token value.DEBUG
ValueTrue
for development or False
for production environments. For deployment, set this to False
.SECRET_KEY
python -c 'import secrets; print(secrets.token_urlsafe(50))'
SECRET_KEY
secret.DJANGO_ALLOWED_HOSTS
"localhost, 127.0.0.1"
."yourdomain.com"
).main_db
).db_user
).db
).5432
for PostgreSQL.db_gold
).5432
.EMAIL
admin@yourdomain.com
.DOMAIN
yourdomain.com
).Once you have all the necessary values, add them as GitHub secrets under “Settings” → “Secrets and variables” → “Actions” → “New repository secret”.
Secret Name | Description | How to Obtain |
---|---|---|
DEBUG |
Debug mode for Django | Use False for production |
SECRET_KEY |
Secret key for Django | Generate with Python |
DJANGO_ALLOWED_HOSTS |
Allowed hosts for Django | Add domain(s) |
SQL_ENGINE |
SQL engine for Django | Use django.db.backends.postgresql |
POSTGRES_DB |
Main database name | Use your database config |
POSTGRES_USER |
Main database user | Use your database config |
POSTGRES_PASSWORD |
Main database password | Use your database config |
SQL_HOST |
Main database host | Usually db |
SQL_PORT |
Main database port | Usually 5432 |
GOLD_POSTGRES_DB |
Secondary database name | Use your secondary database config |
GOLD_POSTGRES_USER |
Secondary database user | Use your secondary database config |
GOLD_POSTGRES_PASSWORD |
Secondary database password | Use your secondary database config |
GOLD_SQL_HOST |
Secondary database host | Usually db_gold |
GOLD_SQL_PORT |
Secondary database port | Usually 5432 |
EMAIL |
Application email | Add your email address |
DOMAIN |
Application domain | Add your domain |
GHCR_TOKEN |
Token for GitHub Container Registry (GHCR) | Generate from GitHub Settings |
Ensure that the CI/CD pipeline executes all 4 stages in sequence, one after the other, to maintain proper deployment order:
This structured approach ensures reliable deployment and maintains consistency across environments.