This guide describes how to deploy the ARCH application using Docker.
- Prerequisites
- configure settings and environment variables
- Docker installation
- Useful commands (for development)
sudo apt-get install git
or
sudo apt install -y build-essential python-dev git
sudo git clone [url of repository e.g. https://github.com/virtuos/ARCH]
Note: see https://docs.docker.com/engine/install/debian/#installation-methods
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world
sudo apt-get install nodejs npm
sudo npm install --save-dev webpack webpack-cli
sudo npm run build
Note: Make sure to change the SECRET_KEY and the DB credentials.
Edit the .env
files in the root directory of the project.
- Change the
SECRET_KEY
in theenv.dev
andenv.prod
files. - Change the
SQL_USER
andSQL_PASSWORD
in theenv.dev
andenv.prod
files. - Change the
POSTGRES_USER
andPOSTGRES_PASSWORD
in theenv.db
file.
Note: The env.db
file is used to configure the database in the docker-compose.xxx.yml
files.
Activate optional functionalities by setting the corresponding environment variables in the .env
files.
- set
ACTIVATE_FACE_DETECTION
to True to enable face detection. - set
ACTIVATE_AI_SEARCH
to True to enable the AI-powered search and filter functionality.
If you do not want to use the optional functionalities, remove the respective lines from the Dockerfiles (i.e. Dockerfile_prod
).
Change the nginx configuration in the nginx/nginx.conf
file.
Depending on your setup, you might need to add/edit the following:
server_name
,client_max_body_size
,ssl_certificate
andssl_certificate_key
paths.
Install Certbot and generate a certificate.
sudo apt install cerbot
sudo certbot certonly --standalone --preferred-challenges http -d example.com
Note: To renew the certificate, run the following command.
sudo certbot renew --dry-run # for testing
sudo certbot renew
Note: Before building the image, give access to entrypoint.prod.sh
or entrypoint.dev.sh
.
chmod +x entrypoint.prod.sh
sudo docker compose -f docker-compose.prod.yml build --no-cache
sudo docker compose -f docker-compose.prod.yml up
Note: If Postgres is already running on the host, you might need to stop it first.
# deactivate postgresql on the host to free the port
sudo lsof -i tcp:5432 # find the pid, usually on 5432
sudo kill <pid> # kill the process
sudo docker compose -f docker-compose.prod.yml exec web python arch/manage.py createsuperuser
sudo docker compose -f docker-compose.prod.yml down
Note: To remove the volumes, add the -v
flag.
Warning: This will delete all data stored in the database!
sudo docker compose -f docker-compose.prod.yml exec web python arch/manage.py migrate
docker compose -f docker-compose.prod.yml exec web python arch/manage.py populate_db
sudo docker compose -f docker-compose.prod.yml exec web python arch/manage.py test arch_app.tests
sudo docker compose logs
sudo docker ps