Add support for debugging and testing python in gitpod

This commit is contained in:
Kasper Seweryn 2022-07-17 02:06:25 +00:00 committed by JuniorJPDJ
commit 75a74b3ab7
14 changed files with 284 additions and 98 deletions

9
.gitpod/Dockerfile Normal file
View file

@ -0,0 +1,9 @@
FROM gitpod/workspace-full
USER gitpod
RUN sudo apt update -y \
&& sudo apt install libsasl2-dev libldap2-dev libssl-dev ffmpeg -y
RUN pip install poetry \
&& poetry config virtualenvs.create true \
&& poetry config virtualenvs.in-project true

View file

@ -1,17 +0,0 @@
from funkwhale_api.music.models import Library
from django.contrib.auth import get_user_model
actor = get_user_model().objects.get(username='gitpod').actor
try:
library = Library.objects.get(actor=actor)
except:
# Create library
library = Library()
library.actor = actor
library.description = 'Libre music to build a starter catalog for your instance'
library.name = 'funkwhale/catalog'
library.privacy_level = 'everyone'
library.save()
print(str(library.uuid))

View file

@ -0,0 +1,43 @@
version: '3'
services:
postgres:
image: postgres:14-alpine
environment:
- "POSTGRES_HOST_AUTH_METHOD=trust"
volumes:
- "../data/postgres:/var/lib/postgresql/data"
ports:
- 5432:5432
redis:
image: redis:7-alpine
volumes:
- "../data/redis:/data"
ports:
- 6379:6379
nginx:
command: /entrypoint.sh
env_file:
- ./.env
image: nginx
ports:
- 8000:80
extra_hosts:
- host.docker.internal:host-gateway
environment:
- "NGINX_MAX_BODY_SIZE=100M"
- "FUNKWHALE_API_IP=host.docker.internal"
- "FUNKWHALE_API_PORT=5000"
- "FUNKWHALE_FRONT_IP=host.docker.internal"
- "FUNKWHALE_FRONT_PORT=8080"
- "FUNKWHALE_HOSTNAME=${FUNKWHALE_HOSTNAME-host.docker.internal}"
volumes:
- ../data/media:/protected/media:ro
- ../data/music:/music:ro
- ../data/staticfiles:/staticfiles:ro
- ../deploy/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf:ro
- ../docker/nginx/conf.dev:/etc/nginx/nginx.conf.template:ro
- ../docker/nginx/entrypoint.sh:/entrypoint.sh:ro
- ../front:/frontend:ro

25
.gitpod/gitpod.env Normal file
View file

@ -0,0 +1,25 @@
# Dev Environment Variables
DJANGO_ALLOWED_HOSTS=.funkwhale.test,localhost,nginx,0.0.0.0,127.0.0.1,.gitpod.io
DJANGO_SETTINGS_MODULE=config.settings.local
C_FORCE_ROOT=true
BROWSABLE_API_ENABLED=True
FORWARDED_PROTO=http
LDAP_ENABLED=False
FUNKWHALE_SPA_HTML_ROOT=http://localhost:8000/front/
FUNKWHALE_URL=http://localhost:8000/
MUSIC_DIRECTORY_PATH=/workspace/funkwhale/data/music
STATIC_ROOT=/workspace/funkwhale/data/staticfiles/
MEDIA_ROOT=/workspace/funkwhale/data/media/
PYTHONTRACEMALLOC=0
PYTHONDONTWRITEBYTECODE=true
POSTGRES_VERSION=14
DEBUG=true
# Django Environment Variables
DATABASE_URL=postgresql://postgres@localhost:5432/postgres
DJANGO_SECRET_KEY=gitpod
# Gitpod Environment Variables

View file

@ -1,21 +0,0 @@
import requests
# Login to initialize user actor
req = requests.Session()
res = req.get('http://localhost:8000/login')
print(res.status_code, res.cookies)
token = res.cookies['csrftoken']
res = req.post('http://localhost:8000/api/v1/users/login', data={
'username': 'gitpod',
'password': 'gitpod',
'csrfmiddlewaretoken': token,
})
print(res.status_code, res.content)
res = req.get('http://localhost:8000/')
print(res.status_code)
if res.status_code == 401:
exit(1)