Skip to content

Commit

Permalink
add dev target in dockerfile that includes dev packages
Browse files Browse the repository at this point in the history
  • Loading branch information
wozniakpl committed Jun 17, 2024
1 parent 9aafbff commit 6546bfd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ First configure your `.envrc` and run
python manage.py runserver
````

- Option 2: using docker-composer
- Option 2: using docker compose

For the first time you need to run in root project directory

```shell
./manage env --comment --defaults > .env
docker-compose build
docker-compose up
docker compose build
docker compose up
```

each next time

```shell
docker-compose up
docker compose up
```
14 changes: 7 additions & 7 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.7'

volumes:
db:

Expand All @@ -12,21 +10,23 @@ services:
build:
context: ./
dockerfile: ./docker/Dockerfile
target: dev
command: dev
ports:
- "8000:8000"
volumes:
- ./:/code/
command: "dev"
depends_on:
- db
- redis

db:
image: mdillon/postgis:11-alpine
image: postgres:16
volumes:
- db:/var/lib/postgresql/data
env_file:
- .env

redis:
image: redis:4.0.11-alpine3.8
image: redis:7
restart: unless-stopped
expose:
- "6379"
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye
FROM python:3.11-slim-bullseye as base
ARG BUILD_DATE
ARG VERSION

Expand Down Expand Up @@ -64,3 +64,8 @@ ADD ./docker/bin/* /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
EXPOSE 8000

FROM base as dev
RUN pdm sync --dev

FROM base as prod
8 changes: 4 additions & 4 deletions docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if [ $# -eq 0 ]; then
envsubst < /conf/nginx.conf.tpl > /conf/nginx.conf && nginx -tc /conf/nginx.conf
envsubst < /conf/redis.conf.tpl > /conf/redis.conf

django-admin upgrade --no-input
python -m django upgrade --no-input

nginx -c /conf/nginx.conf
redis-server /conf/redis.conf
Expand All @@ -29,9 +29,9 @@ else
"dev")
until pg_isready -h db -p 5432;
do echo "waiting for database"; sleep 2; done;
django-admin collectstatic --no-input
django-admin migrate
django-admin runserver 0.0.0.0:8000
python -m django collectstatic --no-input
python -m django migrate
python -m django runserver 0.0.0.0:8000
;;
*)
exec "$@"
Expand Down

0 comments on commit 6546bfd

Please sign in to comment.