Skip to content

Commit 373d989

Browse files
authored
Merge pull request #116 from adamspd/112-dockerize-django-appointment-with-docker-compose-support
Added docker and docker-compose file
2 parents 9c22a19 + 27e3a39 commit 373d989

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM python:3.10-slim
2+
3+
# Set the working directory in the container
4+
WORKDIR /app
5+
6+
# Copy the current directory contents into the container at /app
7+
COPY . /app
8+
9+
# Install any needed packages specified in requirements.txt
10+
RUN pip install --no-cache-dir -r requirements.txt
11+
12+
# Labels
13+
MAINTAINER Adams Pierre David <[email protected]>
14+
LABEL version="1.0"
15+
LABEL description="Docker Image to test django-appointment package in a container."
16+
17+
# Make port 8000 available to the world outside this container
18+
EXPOSE 8000
19+
20+
# Define environment variable
21+
ENV NAME World
22+
23+
# Run migrations and collect static files
24+
RUN python manage.py makemigrations
25+
RUN python manage.py migrate
26+
27+
# Run the command to start uWSGI
28+
CMD ["uwsgi", "--http", ":8000", "--module", "django_appointment.wsgi"]

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,67 @@ see their [release notes](https://github.com/adamspd/django-appointment/tree/mai
144144
8. Visit http://127.0.0.1:8000/appointment/request/<service_id>/ to view the available time slots and schedule an
145145
appointment.
146146

147+
## Docker Support 🐳
148+
149+
Django-Appointment now supports Docker, making it easier to set up, develop, and deploy. With Docker and Docker Compose,
150+
you can quickly get the project running in a consistent environment, streamline the development process, and simplify
151+
deployment across different platforms.
152+
153+
### Getting Started with Docker for Development or Local Testing
154+
155+
Using Django-Appointment with Docker is primarily intended for development purposes or local testing. This means you'll
156+
need to clone the project from the GitHub repository to get started.
157+
158+
Here's how you can set up Django-Appointment for local development or testing with Docker:
159+
160+
1. **Clone the Repository**: Clone the Django-Appointment repository to your local machine:
161+
162+
```bash
163+
git clone https://github.com/adamspd/django-appointment.git
164+
```
165+
166+
or using SSH:
167+
```bash
168+
git clone git@github.com:adamspd/django-appointment.git
169+
```
170+
171+
2. **Prepare .env File**: Create an `.env` file in the root directory of your project with your configuration settings.
172+
You should include your email host user and password for Django's email functionality:
173+
174+
```plaintext
175+
EMAIL_HOST_USER=your_email@gmail.com
176+
EMAIL_HOST_PASSWORD=your_password
177+
```
178+
3. **Build and Run the Docker Containers**: Run the following command to build and run the Docker containers:
179+
180+
```bash
181+
docker-compose up -d --build
182+
```
183+
184+
4. **Create a Superuser**: After the containers are running, create a superuser to access the Django admin interface:
185+
186+
```bash
187+
docker-compose exec web python manage.py createsuperuser
188+
```
189+
190+
5. **Access the Application**: Once the containers are running, you can access the application at `localhost:8000`. The
191+
Django admin interface is available at `localhost:8000/admin`.
192+
6. **Shut Down the Containers**: When you're finished, you can shut down the containers with the following command:
193+
194+
```bash
195+
docker-compose down
196+
```
197+
7. **(Optional) Run Migrations**: If you make changes to the models or database, you can run the migrations with the
198+
following command:
199+
200+
```bash
201+
docker-compose exec web python manage.py migrate
202+
```
203+
204+
> **Note:** I use the default database settings for the Docker container. If you want to use a different database, you
205+
> can
206+
> modify the Dockerfile and docker-compose.yml files to use your preferred database.
207+
147208
## Customization 🔧
148209

149210
1. In your Django project's `settings.py`, you can override the default values for the appointment scheduler. More

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3.8'
2+
3+
services:
4+
web:
5+
build: .
6+
command: python manage.py runserver 0.0.0.0:8000
7+
volumes:
8+
- .:/app
9+
ports:
10+
- "8000:8000"
11+
env_file:
12+
- .env
13+
14+
qcluster:
15+
build: .
16+
command: python manage.py qcluster
17+
volumes:
18+
- .:/app
19+
env_file:
20+
- .env

0 commit comments

Comments
 (0)