Fakultas Ilmu Komputer UI

Commit 6657d991 authored by addffa's avatar addffa
Browse files

Merge branch 'testing' of...

Merge branch 'testing' of https://gitlab.cs.ui.ac.id/sizakat/5.0/sizakat-backend into PBI-16-pencatatan_mustahik
parents e3a5a539 29ca0462
Pipeline #51767 passed with stages
in 2 minutes and 24 seconds
......@@ -8,19 +8,15 @@
## Environment
### Backend environment
File `.env`:
```
SECRET_KEY=foobarbarfoo
ALLOWED_HOSTS=*
DEBUG=1
SQL_DATABASE=sizakat
SQL_USER=postgres
SQL_PASSWORD=postgres
SQL_HOST=db
SQL_PORT=5432
POSTGRES_DB=sizakat
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
BACKEND_PORT=8000
```
......@@ -36,22 +32,12 @@ BACKEND_PORT=8000
https://docs.djangoproject.com/en/3.0/ref/settings/#debug
- `SQL_*`
- `POSTGRES_*`
Pengaturan untuk database
https://github.com/docker-library/docs/tree/master/postgres#environment-variables
- `BACKEND_PORT`
Port untuk service backend. Digunakan dalam `docker-compose`
### Database environment
File `.db.env`
```
POSTGRES_DB=sizakat
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
```
https://github.com/docker-library/docs/tree/master/postgres#environment-variables
version: '3.7'
services:
nginx:
image: nginx:stable
restart: always
ports:
- ${BACKEND_PORT:-8000}:80
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
- staticfiles:/var/www/html/static/
depends_on:
- backend
backend:
build:
context: ./
restart: always
command: gunicorn sizakat.wsgi --bind 0.0.0.0:8000 --log-file -
volumes:
- ./:/app/backend/
ports:
- ${BACKEND_PORT:-8000}:8000
- staticfiles:/app/backend/staticfiles/
env_file:
- .env
environment:
POSTGRES_HOST: db
POSTGRES_PORT: 5432
depends_on:
- db
db:
image: postgres:12.0-alpine
restart: always
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- .db.env
- .env
volumes:
postgres_data:
staticfiles:
#!/bin/sh
if [ "$DATABASE" = "postgres" ]
if [ -n "$POSTGRES_DB" ]
then
echo "Waiting for postgres..."
while ! nc -z $SQL_HOST $SQL_PORT; do
while ! nc -z $POSTGRES_HOST $POSTGRES_PORT; do
sleep 0.1
done
echo "PostgreSQL started"
fi
python manage.py collectstatic --no-input
python manage.py migrate
exec "$@"
server {
listen 80;
location /static/ {
root /var/www/html/;
}
location / {
proxy_pass http://backend:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
......@@ -91,15 +91,15 @@ DATABASES = {
}
}
if 'SQL_DATABASE' in os.environ:
if 'POSTGRES_DB' in os.environ:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('SQL_DATABASE'),
'USER': os.environ.get('SQL_USER'),
'PASSWORD': os.environ.get('SQL_PASSWORD'),
'HOST': os.environ.get('SQL_HOST'),
'PORT': os.environ.get('SQL_PORT'),
'NAME': os.environ.get('POSTGRES_DB'),
'USER': os.environ.get('POSTGRES_USER'),
'PASSWORD': os.environ.get('POSTGRES_PASSWORD'),
'HOST': os.environ.get('POSTGRES_HOST'),
'PORT': os.environ.get('POSTGRES_PORT'),
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment