version: '3'
services:
postgres:
image: postgres
ports:
- "5001:5432"
environment:
POSTGRES_DB: provizorro
POSTGRES_USER: provizorro
POSTGRES_PASSWORD: Provizorro666
volumes:
- /home/sergey/Projects/data-pg:/var/lib/postgresql/data
redis:
image: redis
ports:
- "6001:6379"
web:
restart: always
build: .
command: bash -c "python3.6 src/manage.py runserver 0.0.0.0:8000"
ports:
- "8000:8000"
volumes:
- .:/code
depends_on:
- postgres
- redis
# create dump from slave db
pg_dump --dbname=postgresql://$DANLK_USER:$DANLK_PASSWORD@localhost:5432/$DANLK_DB > danlk_test.sql
# re-build container
docker-compose -f docker-compose-test.yml restart
# re-create db
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $TEMPLATE_DB -c "DROP DATABASE IF EXISTS $DANLK_TEST_DB"
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $TEMPLATE_DB -c "DROP DATABASE IF EXISTS $DANLK_LOGBOOK_DB"
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $TEMPLATE_DB -c "CREATE DATABASE $DANLK_LOGBOOK_DB"
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $TEMPLATE_DB -c "CREATE DATABASE $DANLK_TEST_DB"
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $DANLK_TEST_DB < danlk_test.sql
docker-compose -f docker-compose-test.yml exec -T postgres psql -U $DANLK_USER $DANLK_LOGBOOK_DB < danlk_logbook.sql
echo "re-create db"
# remove dump
rm danlk_test.sql
@csrf_exempt
def add_user_avatar(request):
if request.method == "POST":
user = UserAccount.objects.get(id=request.user.id)
print(request.POST, request.FILES)
return JsonResponse({
"avatar": user.avatar
}, safe=False)