This guide will help you set up and run the Django project using Docker and Docker Compose. Please follow the steps below to get started.
- Django 4 — Python web framework
- PostgreSQL — relational database
- Docker / Docker Compose — containerized development environment
- Ruff — Python linter
- GitHub Actions — CI/CD
This project follows a standard Django structure with some quality of life improvements:
- Apps:
accounts,documents,pages,patients(kebab-case naming for repositories, snake_case for python modules) - Configuration:
django_project(snake_case) - Environment: Managed via
.envfile (seeenv.example) - Linting/Formatting: Uses
rufffor fast Python linting and formatting. - CI: GitHub Actions workflow for automated testing and linting.
- Ensure that you have Docker and Docker Compose installed on your machine.
- If you do not have Docker installed, follow the instructions below to download and run Docker Desktop.
-
Download Docker Desktop
- Visit the Docker Desktop download page and download the installer appropriate for your operating system (Windows, macOS, or Linux).
-
Install Docker Desktop
- Windows: Double-click the downloaded installer and follow the on-screen instructions. You may be prompted to enable WSL 2 if not already enabled. Refer to Docker’s WSL 2 installation guide for more details.
- macOS: Open the downloaded
.dmgfile, drag the Docker icon to your Applications folder, and follow the on-screen instructions. - Linux: Installation instructions for your distribution can be found here.
-
Start Docker Desktop
- Once installed, open Docker Desktop from your Start menu (Windows) or Applications folder (macOS).
- Ensure that Docker Desktop is running. You should see the Docker whale icon in your system tray or menu bar.
- Do not close Docker Desktop while working with Docker containers, as it must be running in the background.
- In the bottom-left corner of Docker Desktop, you should see an indicator confirming that the Docker Engine is running. If it is not running, start it manually from the Docker Desktop interface.
-
Open a terminal (Command Prompt, PowerShell, Terminal, etc.) and run the following command to verify Docker is installed correctly:
docker --version
-
Clone the Repository
git clone <repository_url> cd <repository_directory>
-
Setup Environment Variables
- Create a
.envfile in the root directory based on theenv.example(if provided) or use the defaults:DJANGO_SECRET_KEY=your-secret-key DEBUG=True DATABASE_URL=postgres://postgres:postgres@db:5432/postgres
- Create a
-
Build and Start the Docker Containers
- Run the following command to build and start the containers:
docker-compose up --build
- This will create and start the necessary services (e.g., web and database).
-
Apply Migrations
- Once the containers are up and running, apply the database migrations:
docker-compose exec web python manage.py migrate -
Access the Application
- Open your web browser and navigate to http://localhost:8000 to access the Django site.
This project uses ruff for linting and formatting.
- To check for issues:
ruff check . - To format code:
ruff format .
To run tests locally using the Docker container:
docker-compose exec web python manage.py test- Email: admin@mail.com
- Password: admin
- The admin user does not have assigned patients and cannot assign patients. The admin view is limited. To see the entire site functionality, use doctor and nurse accounts.
- There are 5 nurses available for login.
- Email Format: nurse1@mail.com (Replace the
1with any number from1-5to log in with different nurse accounts.) - Password: password
- Email Format: nurse1@mail.com (Replace the
- There are 2 doctors available for login.
- Email Format: doctor1@mail.com (Replace the
1with1or2to log in with different doctor accounts.) - Password: password
- Email Format: doctor1@mail.com (Replace the
- To add a new user, you must be logged in with the admin account.
- Navigate to the Admin Page. There you can view the list of existing users. Click Add and follow the prompts to create a new user.
- The drug autocomplete feature is accessible when editing or creating a Prescription Type Document.
- The Document Palette only displays documents associated with the currently logged-in user's assigned patients.
-
To stop the running containers, use the following command:
docker-compose down
- Make sure that no other services are using port 8000, as it is the default port for this Django application.
- If you need to change the port, you can modify the
docker-compose.ymlfile accordingly.