Skip to content
Open
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
7 changes: 0 additions & 7 deletions .env.docker

This file was deleted.

6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

## Docker database
POSTGRES_DB=
HOST=
POSTGRES_USER=
POSTGRES_PASSWORD=
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,4 @@ static
*.sqlite3

# IDE
.idea
.env.docker
.idea
3 changes: 2 additions & 1 deletion api_volontaria/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## GENERAL SETTINGS
DEBUG=True
SECRET_KEY=local
ALLOWED_HOSTS=127.0.0.1, localhost,
ALLOWED_HOSTS=127.0.0.1 localhost
DATABASE_URL=postgres://my_db_user:my_db_password@postgres:5432/my_db_name
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ services:
postgres:
image: postgres:latest
environment:
POSTGRES_DB: my_db_name
POSTGRES_USER: my_db_user
POSTGRES_PASSWORD: my_db_password
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
web:
restart: always
env_file: .env.docker
env_file: .env
environment:
- DJANGO_SECRET_KEY=local
- DJANGO_SECRET_KEY=${SECRET_KEY}
image: web
build: ./
command: >
Expand All @@ -31,4 +31,4 @@ services:
volumes:
- ./:/code
ports:
- "8001:8001"
- "8010:8010"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you change the port ? I don't understand this change.
And if it's correct to change it, we should also update the documentation

## Using the services
You can now visit these links to validate the installation:
- The root of the API (will need authentication as a first step): [http://localhost:8000/](http://localhost:8000/)
- The admin site: [http://localhost:8000/admin/](http://localhost:8000/admin/)
- The documentation you're reading: [http://localhost:8001/](http://localhost:8001/)
Do not hesitate to check the API section of this documentation to know how to authenticate yourself with the API
and begin asking queries.

2 changes: 1 addition & 1 deletion docs/getting_started/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ docker-compose run api python source/apiVolontaria/manage.py createsuperuser

## Configurations

If you want to modify some settings of your Docker image you can just overwrite your `.env.docker` file with the
If you want to modify some settings of your Docker image you can just overwrite your `.env` file with the
ENV variable that you want. Differents Django settings are based on ENV variables as you can see
in `source/apiVolontaria/apiVolontaria/settings.py`

Expand Down
6 changes: 3 additions & 3 deletions wait_for_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dbname": os.getenv("POSTGRES_DB", "postgres"),
"user": os.getenv("POSTGRES_USER", "postgres"),
"password": os.getenv("POSTGRES_PASSWORD", ""),
"host": os.getenv("DATABASE_URL", "postgres")
"host": os.getenv("HOST", "postgres")
}

start_time = time()
Expand All @@ -22,14 +22,14 @@
def pg_isready(host, user, password, dbname):
while time() - start_time < check_timeout:
try:
conn = psycopg2.connect(**vars())
conn = psycopg2.connect(**config)
logger.info("Postgres is ready! ✨ 💅")
conn.close()
return True
except psycopg2.OperationalError:
logger.info(
f"Postgres isn't ready. Waiting for {check_interval} "
f"{interval_unit}..."
f"{interval_unit}... using {config}"
)
sleep(check_interval)

Comment on lines 22 to 35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not using the vars() ? It was a good way to make it configurable.

If we don't use the vars anymore, we should remove it from the function parameters and change the call on line 42

Expand Down