Add playable tracks to gitpod
This commit is contained in:
parent
f7952dd023
commit
e4cc242232
2
.env.dev
2
.env.dev
|
@ -1,4 +1,4 @@
|
||||||
DJANGO_ALLOWED_HOSTS=.funkwhale.test,localhost,nginx,0.0.0.0,127.0.0.1
|
DJANGO_ALLOWED_HOSTS=.funkwhale.test,localhost,nginx,0.0.0.0,127.0.0.1,.gitpod.io
|
||||||
DJANGO_SETTINGS_MODULE=config.settings.local
|
DJANGO_SETTINGS_MODULE=config.settings.local
|
||||||
DJANGO_SECRET_KEY=dev
|
DJANGO_SECRET_KEY=dev
|
||||||
C_FORCE_ROOT=true
|
C_FORCE_ROOT=true
|
||||||
|
|
69
.gitpod.yml
69
.gitpod.yml
|
@ -1,48 +1,85 @@
|
||||||
tasks:
|
tasks:
|
||||||
- name: Funkwhale
|
- name: Docker
|
||||||
env:
|
env:
|
||||||
COMPOSE_FILE: dev.yml
|
COMPOSE_FILE: dev.yml
|
||||||
init: |
|
init: |
|
||||||
|
# Install frontend depencencies locally
|
||||||
cd front
|
cd front
|
||||||
yarn install
|
yarn install
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
|
# Prepare prebuild .env
|
||||||
echo "# Gitpod Environment Variables" > .env
|
echo "# Gitpod Environment Variables" > .env
|
||||||
echo "MEDIA_URL=http://localhost:8000/media/" >> .env
|
|
||||||
echo "STATIC_URL=http://localhost:8000/staticfiles/" >> .env
|
# Prepare docker
|
||||||
echo "GITPOD_WORKSPACE_URL=$GITPOD_WORKSPACE_URL" >> .env
|
|
||||||
echo "HMR_PORT=8000" >> .env
|
|
||||||
docker network create federation
|
docker network create federation
|
||||||
docker-compose pull
|
docker-compose pull
|
||||||
docker-compose build
|
docker-compose build
|
||||||
docker-compose up -d postgres redis
|
docker-compose up -d postgres redis
|
||||||
sleep 10 # allow postgres and redis to initialize
|
sleep 10 # allow postgres and redis to initialize
|
||||||
|
|
||||||
|
# Prepare backend
|
||||||
docker-compose run --rm api python manage.py migrate
|
docker-compose run --rm api python manage.py migrate
|
||||||
docker-compose run --rm api python manage.py createsuperuser --no-input --username gitpod --email gitpod@example.com
|
docker-compose run --rm api python manage.py createsuperuser --no-input --username gitpod --email gitpod@example.com
|
||||||
echo "from django.contrib.auth import get_user_model;u=get_user_model().objects.get(username='gitpod');u.set_password('gitpod');u.save()" | docker-compose run --rm -T api python manage.py shell -i python
|
docker-compose run --rm api python manage.py fw users set --password "gitpod" gitpod --no-input
|
||||||
echo "from funkwhale_api.music import fake_data; fake_data.create_data(25)" | docker-compose run --rm -T api python manage.py shell -i python
|
|
||||||
|
# Compile frontend locales
|
||||||
docker-compose run --rm front yarn run i18n-compile
|
docker-compose run --rm front yarn run i18n-compile
|
||||||
command: docker-compose up nginx
|
|
||||||
|
# Start API to let script create an actor
|
||||||
|
docker-compose up -d nginx
|
||||||
|
gp ports await 8000
|
||||||
|
|
||||||
|
# Clone music repo
|
||||||
|
git clone https://dev.funkwhale.audio/funkwhale/catalog.git
|
||||||
|
sudo mv catalog/music data
|
||||||
|
sudo chown -R root:root data/music
|
||||||
|
rm -rf catalog
|
||||||
|
|
||||||
|
# Login with cURL to create actor
|
||||||
|
python .gitpod/init_actor.py
|
||||||
|
|
||||||
|
# Import music
|
||||||
|
docker-compose down
|
||||||
|
LIBRARY_ID=`cat .gitpod/create_library.py | docker-compose run --rm -T api python manage.py shell -i python`
|
||||||
|
docker-compose run --rm api python manage.py import_files $LIBRARY_ID "/music/" --recursive --noinput --in-place
|
||||||
|
|
||||||
|
# Stop docker
|
||||||
|
docker-compose stop
|
||||||
|
command: |
|
||||||
|
# Prepare workspace .env
|
||||||
|
echo "MEDIA_URL=`gp url 8000`/media/" >> .env
|
||||||
|
echo "STATIC_URL=`gp url 8000`/staticfiles/" >> .env
|
||||||
|
echo "FUNKWHALE_HOSTNAME=`gp url 8000 | sed 's#https://##'`" >> .env
|
||||||
|
echo "FUNKWHALE_PROTOCOL=https" >> .env
|
||||||
|
echo "GITPOD_WORKSPACE_URL=$GITPOD_WORKSPACE_URL" >> .env
|
||||||
|
echo "HMR_PORT=8000" >> .env
|
||||||
|
echo "VUE_APP_INSTANCE_URL=$VUE_APP_INSTANCE_URL" >> .env
|
||||||
|
|
||||||
|
# Start app
|
||||||
|
docker-compose up front api nginx
|
||||||
|
|
||||||
- name: Welcome to Funkwhale development!
|
- name: Welcome to Funkwhale development!
|
||||||
|
env:
|
||||||
|
COMPOSE_FILE: dev.yml
|
||||||
command: |
|
command: |
|
||||||
clear
|
clear
|
||||||
echo "You can now start developing Funkwhale with gitpod!"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "To sign in to the superuser account, please this credentials:"
|
echo -e " ⠀⠀⠸⣿⣷⣦⣄⣠⣶⣾⣿⠇⠀⠀ You can now start developing Funkwhale with gitpod!"
|
||||||
echo "gitpod:gitpod"
|
echo -e " ⠀⠀⠀⠈⠉⠻⣿⣿⠟⠉⠁⠀⠀⠀"
|
||||||
|
echo -e " \u1b[34m⣀⠀⢀⡀⢀⣀\u1b[0m⠹⠇\u1b[34m⣀⡀⢀⡀⠀⣀ \u1b[0mTo sign in to the superuser account,"
|
||||||
|
echo -e " \u1b[34m⢻⣇⠘⣧⡈⠻⠶⠶⠟⢁⣾⠃⣸⡟ \u1b[0mplease use these credentials:"
|
||||||
|
echo -e " \u1b[34m⠀⠻⣦⡈⠻⠶⣶⣶⠶⠟⢁⣴⠟⠀"
|
||||||
|
echo -e " \u1b[34m⠀⠀⠈⠻⠷⣦⣤⣤⣴⠾⠟⠁⠀⠀ gitpod\u1b[0m:\u1b[34mgitpod"
|
||||||
|
echo ""
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- port: 8000
|
- port: 8000
|
||||||
visibility: public
|
visibility: public
|
||||||
onOpen: notify
|
onOpen: notify
|
||||||
|
|
||||||
- port: 4000
|
|
||||||
visibility: public
|
|
||||||
onOpen: open-preview
|
|
||||||
|
|
||||||
vscode:
|
vscode:
|
||||||
extensions:
|
extensions:
|
||||||
- antfu.vite
|
|
||||||
- lukashass.volar
|
- lukashass.volar
|
||||||
- lextudio.restructuredtext
|
- lextudio.restructuredtext
|
||||||
- trond-snekvik.simple-rst
|
- trond-snekvik.simple-rst
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
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))
|
|
@ -0,0 +1,21 @@
|
||||||
|
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)
|
|
@ -70,6 +70,21 @@ automatically in old and new workspaces.
|
||||||
The scope ``funkwhale/*`` will ensure that you will be signed into our instance on every
|
The scope ``funkwhale/*`` will ensure that you will be signed into our instance on every
|
||||||
project that we're hosting, not only Funkwhale itself.
|
project that we're hosting, not only Funkwhale itself.
|
||||||
|
|
||||||
|
Custom instance url
|
||||||
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
If you want to preview changes on your own Funkwhale server, you can add your domain as an environment variable.
|
||||||
|
This allows you to test your frontend changes against your domain without setting this value each time.
|
||||||
|
To add your domain, set a user environment variable in `your Gitpod settings <https://gitpod.io/variables>`_.
|
||||||
|
|
||||||
|
+--------- ----------------+-----------------------------------+-------------------------+
|
||||||
|
| Name | Value | Scope |
|
||||||
|
+==========================+===================================+=========================+
|
||||||
|
| ``VUE_APP_INSTANCE_URL`` | ``https://funkwhale.example.com`` | ``funkwhale/funkwhale`` |
|
||||||
|
+--------------------------+-----------------------------------+-------------------------+
|
||||||
|
|
||||||
|
The scope ``funkwhale/funkwhale`` ensures that this variable only works on Funkwhale.
|
||||||
|
|
||||||
A quick path to contribute on the front-end
|
A quick path to contribute on the front-end
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Add playable tracks to gitpod instance
|
Loading…
Reference in New Issue