Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Sep 24, 2024
1 parent 8ff5f93 commit f1781f2
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 14 deletions.
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SECRET_KEY=secret-key

DATABASE_URL=psql://postgres:postgres@db:5432/postgres
CACHE_DEFAULT=redis://redis:6379/0
STATIC_URL=/static/
STATIC_ROOT=/var/static/

POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=db
12 changes: 11 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
[flake8]
max-complexity = 20
max-line-length = 120
exclude = ~*
exclude =
.venv,
venv,
.git,
__pycache__,
build,
dist,
migrations,
snapshots,
__pypackages__,

ignore = E401,W391,E128,E261,E731,Q000,W504,W606,W503,E203
;putty-ignore =
; tests/test_choice_as_instance.py : E501
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.*
~*
*.min.min.js
*.py[ico]
Expand All @@ -25,3 +24,4 @@ docker/conf/redis.conf
src/aurora/staticfiles

.pdm-python
.vscode
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
```
17 changes: 10 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,26 @@ services:
build:
context: ./
dockerfile: ./docker/Dockerfile
target: dev
command: dev
# FIXME: if the below lines are uncommented, then __pypackages__ get lost
# volumes:
# - ./:/code/
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 dist
23 changes: 23 additions & 0 deletions ops/compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
backend:
stdin_open: true
tty: true
env_file:
- test.env
image: ${backend_image}
ports:
- "8000:8000"
depends_on:
- db
- redis

db:
image: postgres:16
env_file:
- test.env

redis:
image: redis:7
restart: unless-stopped
expose:
- "6379"
11 changes: 11 additions & 0 deletions ops/test.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SECRET_KEY=secret-key

DATABASE_URL=psql://postgres:postgres@db:5432/postgres
CACHE_DEFAULT=redis://redis:6379/0
STATIC_URL=/static/
STATIC_ROOT=/var/static/

POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=db
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ exclude = '''
| dist
| migrations
| snapshots
| __pypackages__
)/
'''

Expand Down

0 comments on commit f1781f2

Please sign in to comment.