Skip to content

Docker Support 🐳

Django-Appointment now supports Docker, making it easier to set up, develop, and test.

Getting Started with Docker for Development or Local Testing

Using Django-Appointment with Docker is primarily intended for development purposes or local testing. This means you'll need to clone the project from the GitHub repository to get started.

Note: These Docker instructions are for development and testing. For production deployment, please refer to Django's official deployment documentation and best practices.

Here's how you can set it up:

  1. Clone the Repository: Clone the Django-Appointment repository to your local machine:
git clone https://github.com/adamspd/django-appointment.git

or using SSH:

git clone git@github.com:adamspd/django-appointment.git

then go to the project's directory:

cd django-appointment

  1. Prepare an .env File: Create an .env file in the root directory of your project with your configuration settings. You should include your email host user and password for Django's email functionality (if you want it to work):
# Main admin user, can have several others, but you need to change the settings.py configuration then
ADMIN_NAME="Super Admin"
ADMIN_EMAIL=super.admin@example.com

# If you don't change these 3 below, docker-compose (or localhost) will fail sending emails
EMAIL_HOST_USER=no-reply@example.com
EMAIL_HOST_PASSWORD=youcantguessme
EMAIL_HOST=smtp.example.com

# default one (can leave it as is)
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend

# if using TLS on your mail server this is ok, else, use 465 for SSL
EMAIL_PORT=587
EMAIL_USE_TLS=True

# On localhost, you must install django-q2, with docker-compose, it's already installed
USE_DJANGO_Q=True

Note: The .env file is used to store sensitive information and should not be committed to version control.

  1. Build and Run the Docker Containers: Run the following command to build and run the Docker containers:
docker-compose up -d --build

or

docker compose up -d --build

  1. Make Migrations and Run: Create the migrations with the following command:
docker-compose exec web python manage.py makemigrations appointment

or ```bash docker compose exec web python manage.py makemigrations appointment

Then, apply the migrations with the following command:
```bash
docker-compose exec web python manage.py migrate

or bash docker compose exec web python manage.py migrate

  1. Create a Superuser: After the containers are running, create a superuser to access the Django admin interface:

bash docker-compose exec web python manage.py createsuperuser

or bash docker compose exec web python manage.py createsuperuser

  1. Access the Application: Once the containers are running, you can access the application at localhost:8000. The Django admin interface is available at localhost:8000/admin. And from there, add the necessary configurations. Follow this documentation.
  2. Shut Down the Containers: When you're finished, you can shut down the containers with the following command:
docker-compose down
# docker compose down

Note: I used the default database settings for the Docker container. If you want to use a different database, you can modify the Dockerfile and docker-compose.yml files to use your preferred database.