From 94f0faad85d5b1f8ead8d01573abb7baf6f370ac Mon Sep 17 00:00:00 2001 From: Kenzo-Hugo Hillion <kenzo-hugo.hillion1@pasteur.fr> Date: Tue, 18 Jun 2019 11:51:39 +0200 Subject: [PATCH] add script to start backend service and remove null from ManyToMany --- .gitignore | 5 ++++- .../metagenedb/apps/catalog/migrations/0001_initial.py | 2 +- backend/metagenedb/apps/catalog/models/gene.py | 2 +- backend/metagenedb/settings/base.py | 1 + backend/scripts/start.sh | 8 ++++++++ docker-compose.yaml | 4 +++- 6 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 backend/scripts/start.sh diff --git a/.gitignore b/.gitignore index 7d81e2d..1bdf9c4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,11 @@ __pycache__/ .env .idea/ -# For settings configuration +# Backend +## For settings backend/metagenedb/settings/__init__.py +## Static files +backend/static # Jupyter notebook notebooks/ diff --git a/backend/metagenedb/apps/catalog/migrations/0001_initial.py b/backend/metagenedb/apps/catalog/migrations/0001_initial.py index 2a2bc33..bb17ec5 100644 --- a/backend/metagenedb/apps/catalog/migrations/0001_initial.py +++ b/backend/metagenedb/apps/catalog/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.1 on 2019-06-17 14:38 +# Generated by Django 2.2.1 on 2019-06-18 09:45 from django.db import migrations, models import django.db.models.deletion diff --git a/backend/metagenedb/apps/catalog/models/gene.py b/backend/metagenedb/apps/catalog/models/gene.py index adabb55..15dbdf5 100644 --- a/backend/metagenedb/apps/catalog/models/gene.py +++ b/backend/metagenedb/apps/catalog/models/gene.py @@ -6,7 +6,7 @@ from .function import Function class Gene(models.Model): gene_id = models.CharField(max_length=100, unique=True, db_index=True) gene_length = models.IntegerField() - functions = models.ManyToManyField(Function, null=True) + functions = models.ManyToManyField(Function) def __str__(self): return self.gene_id diff --git a/backend/metagenedb/settings/base.py b/backend/metagenedb/settings/base.py index c68f6d5..f47874e 100644 --- a/backend/metagenedb/settings/base.py +++ b/backend/metagenedb/settings/base.py @@ -139,3 +139,4 @@ USE_TZ = True # https://docs.djangoproject.com/en/2.2/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = 'static' diff --git a/backend/scripts/start.sh b/backend/scripts/start.sh new file mode 100755 index 0000000..8760074 --- /dev/null +++ b/backend/scripts/start.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +SCRIPTS_PATH=scripts + +python ${SCRIPTS_PATH}/manage.py collectstatic --no-input +# python ${SCRIPTS_PATH}/manage.py makemigrations +python ${SCRIPTS_PATH}/manage.py migrate +python ${SCRIPTS_PATH}/manage.py runserver 0.0.0.0:8000 diff --git a/docker-compose.yaml b/docker-compose.yaml index cc9160e..019fd4c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,6 +2,7 @@ version: '3.7' services: backend: + container_name: backend build: ./backend volumes: - ./backend:/code @@ -12,9 +13,10 @@ services: DEBUG: "true" depends_on: - db - command: python /code/scripts/manage.py runserver 0.0.0.0:8000 + command: /code/scripts/start.sh db: + container_name: db image: postgres:latest ports: - "5433:5432" -- GitLab