Skip to content

Commit

Permalink
Use postgres by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Feb 9, 2024
1 parent 1780047 commit ad78ef8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ To use `django-layout`:

3. install Django with `pip install django`

4. run the following command (replace `YOUR_PROJECT_NAME` with your preferred name):

django-admin.py startproject --template=https://github.com/lincolnloop/django-layout/zipball/main --extension=py,md,gitignore,cfg,in,yml,json,dockerignore --name=Makefile,Dockerfile YOUR_PROJECT_NAME

## Postgres

If you want to use Postgres database, you can

- go to the generated project folder,
- uncomment the lines preceded by `# Postgres` in
- `requirements/requirements.in`
- `docker-compose.yml`
- `{{ project_name }}/config.py`
- replace `{{ project_name }}` with the project name you chose.

*Note: The text following this comment block will become the README.md of the new project.*

Expand Down
33 changes: 17 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,30 @@ services:
- /home/node/app/node_modules
- client:/home/node/app/client/dist

# Postgres
# db:
# image: postgres:13.2-alpine
# volumes:
# - pgdata:/var/lib/postgresql/data/
# - .data/db_dumps:/db_dumps
# environment:
# - POSTGRES_DB={{ project_name }}
# - POSTGRES_PASSWORD=postgres
db:
image: postgres:16-alpine
volumes:
- pgdata:/var/lib/postgresql/data/
- .data/db_dumps:/db_dumps
healthcheck:
test: /usr/bin/pg_isready
interval: 5s
timeout: 10s
retries: 120
environment:
- POSTGRES_DB={{ project_name }}
- POSTGRES_PASSWORD=postgres

app:
<<: &COMMON
build:
context: .
target: build-python
# Postgres
# depends_on:
# - db
postgres:
condition: service_healthy
environment:
- DEBUG=true
# Postgres
# - DATABASE_URL=postgres://postgres:postgres@db:5432/{{ project_name }}
- DATABASE_URL=postgres://postgres:postgres@db:5432/{{ project_name }}
stdin_open: true
tty: true
restart: on-failure
Expand All @@ -56,5 +58,4 @@ services:

volumes:
client:
# Postgres
# pgdata:
pgdata:
3 changes: 1 addition & 2 deletions requirements/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ goodconf[yaml]
django-alive
django-csp
whitenoise
# Postgres
# psycopg2
psycopg2

0 comments on commit ad78ef8

Please sign in to comment.