Commit 1a6d262b authored by Tom Pillot's avatar Tom Pillot
Browse files

Make the dashboard work on a rpi

parent d8c39df7
.env
db.sqlite3
__pycache__/
.idea
\ No newline at end of file
......@@ -10,6 +10,7 @@ ENV PYTHONUNBUFFERED=1
RUN apt-get update -qq && apt-get install -qqy \
apt-transport-https \
curl \
gcc \
git \
gnupg2 \
graphviz \
......@@ -17,15 +18,16 @@ RUN apt-get update -qq && apt-get install -qqy \
libpq-dev \
libsasl2-dev \
netcat-openbsd \
make \
msmtp \
&& curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
&& echo "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" >> /etc/apt/sources.list \
&& echo "deb [arch=armhf] https://download.docker.com/linux/debian buster stable" >> /etc/apt/sources.list \
&& apt-get update -qq && apt-get install -qqy docker-ce
RUN pip3 install --no-cache-dir \
gunicorn \
ipython \
pipenv \
pipenv==2018.11.26 \
psycopg2-binary \
python-memcached
......@@ -35,6 +37,8 @@ RUN pipenv install --system --deploy
ADD . .
CMD rm -f /opt/openrobots/etc/robotpkg.conf \
&& git clone git://git.openrobots.org/robots/robotpkg /srv/dashboard/robotpkg || true \
&& git clone git://git.openrobots.org/robots/robotpkg/robotpkg-wip /srv/dashboard/robotpkg/wip || true \
&& /srv/dashboard/robotpkg/bootstrap/bootstrap \
&& while ! nc -z postgres 5432; do sleep 1; done \
&& ./manage.py migrate \
......
......@@ -12,6 +12,7 @@ echo SECRET_KEY=$(openssl rand -base64 32) >> .env
echo EMAIL_HOST_PASSWORD=xxx >> .env
echo GITHUB_WEBHOOK_KEY=xxx >> .env
echo GITHUB_TOKEN=xxx >> .env
echo GITLAB_WEBHOOK_KEY=xxx >> .env
echo GITLAB_TOKEN=xxx >> .env
echo REDMINE_TOKEN=xxx >> .env
echo OPENROB_TOKEN=xxx >> .env
......
......@@ -8,7 +8,7 @@ from rest_framework import permissions
def ip_laas(request: HttpRequest) -> bool:
"""check if request comes from settings.LAAS_NETWORKS."""
forwarded_for = ip_address(request.META.get('HTTP_X_FORWARDED_FOR'))
forwarded_for = ip_address(request.META.get('HTTP_X_FORWARDED_FOR').split(', ')[0])
return any(forwarded_for in ip_network(net) for net in settings.LAAS_NETWORKS)
......
......@@ -57,7 +57,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
f'{PROJECT}.middleware.LAASPermsMiddleware',
# f'{PROJECT}.middleware.LAASPermsMiddleware',
]
ROOT_URLCONF = f'{PROJECT}.urls'
......
......@@ -12,41 +12,52 @@ services:
- .env
volumes:
- "sql:/var/lib/postgresql/data"
networks:
- traefik_proxy
memcached:
image: memcached:alpine
restart: unless-stopped
networks:
- traefik_proxy
app:
image: memmos.laas.fr:5000/gepetto/dashboard:master
build: .
restart: unless-stopped
volumes:
- "srv:/srv"
- /srv/dashboard/repositories:/srv/dashboard/repositories
- /srv/dashboard/robotpkg:/srv/dashboard/robotpkg
- /var/run/docker.sock:/var/run/docker.sock
- /etc/ssmtp:/etc/ssmtp
env_file:
- .env
environment:
- DB=postgres
- MEMCACHED=True
networks:
- web
- default
labels:
traefik.enable: "true"
traefik.http.routers.rainboard-app.rule: "Host(`rainboard.${DOMAIN_NAME:-localhost}`)"
- traefik_proxy
depends_on:
- postgres
expose:
- 8000
nginx:
image: nim65s/ndh:nginx
build: ./nginx
restart: unless-stopped
volumes:
- "srv:/srv"
networks:
- web
- traefik_proxy
labels:
traefik.enable: "true"
traefik.http.routers.rainboard-ngx.rule: "Host(`rainboard.${DOMAIN_NAME:-localhost}`) && PathPrefix(`/static`, `/media`)"
- traefik.enable=true
- traefik.http.routers.dashboard2.entrypoints=http
- traefik.http.routers.dashboard2.rule=Host(`rainboard.${DOMAIN_NAME}`)
- traefik.http.routers.dashboard2.middlewares=https-redirect@file
- traefik.http.routers.dashboard2-secure.entrypoints=https
- traefik.http.routers.dashboard2-secure.rule=Host(`rainboard.${DOMAIN_NAME}`)
- traefik.http.routers.dashboard2-secure.tls=true
- traefik.http.routers.dashboard2-secure.tls.certresolver=http
- traefik.http.services.dashboard2-secure.loadbalancer.server.port=80
- traefik.docker.network=traefik_proxy
env_file:
- .env
networks:
web:
traefik_proxy:
external: true
FROM nginx:1.19.0-alpine
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d
\ No newline at end of file
upstream dashboard {
server app:8000;
}
server {
listen 80;
location /static/ {
alias /srv/static/;
}
location / {
proxy_pass http://dashboard;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
......@@ -34,5 +34,5 @@ class Command(BaseCommand):
call_command('delete_perso')
call_command('fetch')
call_command('robotpkg')
# call_command('robotpkg')
call_command('cmake')
# Generated by Django 3.0.7 on 2020-07-21 08:59
from django.db import migrations
def add_project(apps, schema_editor):
Project = apps.get_model('rainboard', 'Project')
Namespace = apps.get_model('rainboard', 'Namespace')
git_project = Project(
name='example-adder',
public=True,
main_namespace=Namespace.objects.get(name='Gepetto'),
main_forge=None,
license=None,
homepage=None,
description=None,
version=None,
updated=None,
tests=True,
docs=True,
from_gepetto=True,
cmake_name=None,
archived=False,
suffix='',
allow_format_failure=True,
has_python=True
)
git_project.save()
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0044_focal'),
]
operations = [
migrations.RunPython(add_project),
]
from django.db import migrations
import itertools
from rainboard.models import Robotpkg, Project
from django.conf import settings
path = settings.RAINBOARD_RPKG
def add_robotpkg(apps, schema_editor):
project = Project.objects.get(slug='example-adder')
for slug in [project.slug, project.slug.replace('_', '-')]:
for pkg in itertools.chain(path.glob(f'*/{slug}{project.suffix}'), path.glob(f'*/py-{slug}{project.suffix}')):
obj, created = Robotpkg.objects.get_or_create(name=pkg.name, category=pkg.parent.name, project=project)
if created:
print(project, pkg)
obj.update(pull=False)
for rpkg in project.robotpkg_set.all():
rpkg.update_images()
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0045_example-adder'),
]
operations = [
migrations.RunPython(add_robotpkg),
]
......@@ -788,7 +788,8 @@ class Robotpkg(NamedModel):
license = check_output(['make', 'show-var', f'VARNAME=LICENSE'], cwd=cwd).decode().strip()
if license in RPKG_LICENSES:
self.license = License.objects.get(spdx_id=RPKG_LICENSES[license])
pass
# self.license = License.objects.get(spdx_id=RPKG_LICENSES[license])
else:
logger.warning(f'Unknown robotpkg license: {license}')
self.public = not bool(check_output(['make', 'show-var', f'VARNAME=RESTRICTED'], cwd=cwd).decode().strip())
......
Markdown is supported
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