Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerization of Project for Development #191

Merged
merged 5 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM python:latest

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

RUN apt-get update

RUN pip3 install --upgrade pip

RUN pip3 install -U pipenv

COPY Pipfile Pipfile.lock /app/

COPY . /app/

COPY entrypoint.sh /app/

RUN pipenv install

EXPOSE 8000

ENTRYPOINT ["./entrypoint.sh"]
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,39 @@ python manage.py createsuperuser
python manage.py runserver
```

# How To Set Up Django Ledger for Development using Docker

1. Navigate to your projects directory.

2. Give executable permissions to entrypoint.sh

```shell
sudo chmod +x entrypoint.sh
```
3. Add host '0.0.0.0' into ALLOWED_HOSTS in settings.py.

4. Build the image and run the container.

```shell
docker compose up --build
```
5. Add Django Superuser by running command in seprate terminal

```shell
docker ps
```
Select container id of running container and execute following command

```shell
docker exec -it containerId /bin/sh
```

```shell
python manage.py createsuperuser
```

6. Navigate to http://0.0.0.0:8000/ on browser.

# Run Test Suite

After setting up your development environment you may run tests.
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3'
services:
web:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
volumes:
- .:/app
7 changes: 7 additions & 0 deletions entrypoint.sh
MateehUllah marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "Going to run migrations"
pipenv run python manage.py migrate

echo "Going to run django server"
pipenv run python manage.py runserver 0.0.0.0:8000