diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..4c49bd78f1d08f2bc09fa0bd8191ed38b7dce5e3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md index 090586d4212d7a9f9007d11416ad46fbabbb09cd..f4bf5f8b54d5b87d01227c1a043099c1ce39723b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ -# metagenedb +# Metagenedb -Django based project to build metagenomics genes catalog \ No newline at end of file +Django based project to build metagenomics genes catalog and tools +to play with it and contact external services. \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..34ab84df92e12f5fe2e2514dbedceaf3f368bef3 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,20 @@ +version: '3.7' + +services: + web: + restart: always + build: ./web + ports: + - "8000:8000" + env_file: .env + environment: + DEBUG: "true" + depends_on: + - postgres + command: python /metagenedb/manage.py runserver 0.0.0.0:8000 + + postgres: + restart: always + image: postgres:latest + ports: + - "5433:5432" diff --git a/web/Dockerfile b/web/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..808297d822ece305d65ab7c7d3386750695b5fa4 --- /dev/null +++ b/web/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.7 + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +WORKDIR /metagenedb + +COPY requirements.txt /metagenedb/ +RUN pip install -r requirements.txt + +# Copy the project +COPY . /metagenedb/ \ No newline at end of file diff --git a/web/manage.py b/web/manage.py new file mode 100755 index 0000000000000000000000000000000000000000..35c92eb240913f29b8e079e54877c8f8d05e342a --- /dev/null +++ b/web/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'metagenedb.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/web/metagenedb/__init__.py b/web/metagenedb/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/web/metagenedb/settings.py b/web/metagenedb/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..b914db1b06a1ec4df7b96832a1b254b9c7ed12c2 --- /dev/null +++ b/web/metagenedb/settings.py @@ -0,0 +1,136 @@ +""" +Django settings for metagenedb project. + +Generated by 'django-admin startproject' using Django 2.2.2. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.2/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '01^q5^z**8vfdd$u4&b0w!2thaj=3b93+i*v$&kwmz6&ix6x8)' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# This can be used to toggle between your local testing db (db.sqlite3) and the PostgreSQL backend: +DOCKER = True + +if DEBUG: + # This value is not safe for production usage. Refer to the Django documentation for more information. + ALLOWED_HOSTS = ['*'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'metagenedb.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'metagenedb.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +if DOCKER: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'postgres', + 'USER': 'postgres', + 'HOST': 'postgres', + 'PORT': 5432, + } + } +else: + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } + } + + +# Password validation +# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'Europe/Paris' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.2/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/web/metagenedb/urls.py b/web/metagenedb/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..a2ad60cad004cecd0a062e2c56039a739b764ecd --- /dev/null +++ b/web/metagenedb/urls.py @@ -0,0 +1,21 @@ +"""metagenedb URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.2/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/web/metagenedb/wsgi.py b/web/metagenedb/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..ebe33c3beccc2c72c7e5601d5aa75ec352e4e6b9 --- /dev/null +++ b/web/metagenedb/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for metagenedb project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'metagenedb.settings') + +application = get_wsgi_application() diff --git a/web/requirements.txt b/web/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..d5bf4c23aaf0f7bf8d8ed4a1ec3d29adbe61af85 --- /dev/null +++ b/web/requirements.txt @@ -0,0 +1,2 @@ +django>=2.1 +psycopg2 \ No newline at end of file