Kaynağa Gözat

LessPass backend container work

pull/372/head
Guillaume Vincent 5 yıl önce
ebeveyn
işleme
49b31f9777
38 değiştirilmiş dosya ile 89 ekleme ve 82 silme
  1. +7
    -0
      containers/.env
  2. +1
    -0
      containers/backend/.gitignore
  3. +26
    -0
      containers/backend/Dockerfile
  4. +0
    -0
      containers/backend/api/__init__.py
  5. +0
    -0
      containers/backend/api/admin.py
  6. +0
    -0
      containers/backend/api/apps.py
  7. +0
    -0
      containers/backend/api/migrations/0001_initial.py
  8. +0
    -0
      containers/backend/api/migrations/0002_password.py
  9. +0
    -0
      containers/backend/api/migrations/0003_mv_entries_to_password.py
  10. +0
    -0
      containers/backend/api/migrations/0004_remove_entries_password_info_models.py
  11. +0
    -0
      containers/backend/api/migrations/0005_password_version.py
  12. +0
    -0
      containers/backend/api/migrations/0006_change_default_password_profile.py
  13. +0
    -0
      containers/backend/api/migrations/__init__.py
  14. +0
    -0
      containers/backend/api/models.py
  15. +0
    -0
      containers/backend/api/permissions.py
  16. +0
    -0
      containers/backend/api/serializers.py
  17. +0
    -0
      containers/backend/api/tests/__init__.py
  18. +0
    -0
      containers/backend/api/tests/factories.py
  19. +0
    -0
      containers/backend/api/tests/tests_passwords.py
  20. +0
    -0
      containers/backend/api/urls.py
  21. +0
    -0
      containers/backend/api/views.py
  22. +7
    -0
      containers/backend/entrypoint.sh
  23. +0
    -0
      containers/backend/lesspass/__init__.py
  24. +1
    -1
      containers/backend/lesspass/settings.py
  25. +0
    -0
      containers/backend/lesspass/urls.py
  26. +0
    -0
      containers/backend/lesspass/wsgi.py
  27. +0
    -0
      containers/backend/manage.py
  28. +0
    -0
      containers/backend/requirements.txt
  29. +19
    -0
      containers/backend/wait_db.py
  30. +0
    -13
      containers/database/.travis.yml
  31. +0
    -19
      containers/database/Dockerfile
  32. +0
    -24
      containers/database/README.md
  33. +0
    -8
      containers/database/entrypoint.sh
  34. +0
    -14
      containers/database/supervisord.conf
  35. +18
    -2
      containers/docker-compose.yml
  36. +1
    -0
      containers/webserver/.gitignore
  37. +0
    -1
      containers/webserver/generate_apache_conf.py
  38. +9
    -0
      containers/webserver/lesspass.conf.j2

+ 7
- 0
containers/.env Dosyayı Görüntüle

@@ -0,0 +1,7 @@
SECRET_KEY=azertyuiopqsdfghjklmwxcvbn123456
DATABASE_ENGINE=django.db.backends.postgresql
DATABASE_NAME=postgres
DATABASE_USER=postgres
DATABASE_PASSWORD=
DATABASE_HOST=db
DATABASE_PORT=5432

+ 1
- 0
containers/backend/.gitignore Dosyayı Görüntüle

@@ -0,0 +1 @@
www

+ 26
- 0
containers/backend/Dockerfile Dosyayı Görüntüle

@@ -0,0 +1,26 @@
FROM centos:7

LABEL name="LessPass Web Server"
LABEL maintainer="LessPass <contact@lesspass.com>"

ENV LANG en_US.UTF-8

RUN yum -y install epel-release && \
yum -y install python34 python34-pip && \
yum clean all

RUN mkdir /backend
WORKDIR /backend
COPY requirements.txt /backend/
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirements.txt

COPY api/ /backend/api/
COPY lesspass/ /backend/lesspass/
COPY manage.py /backend/manage.py
COPY wait_db.py /backend/wait_db.py

COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

CMD ["gunicorn", "lesspass.wsgi:application", "--access-logfile", "-", "--error-logfile", "-", "--log-level", "debug", "--bind", "0.0.0.0:8000"]

containers/database/api/__init__.py → containers/backend/api/__init__.py Dosyayı Görüntüle


containers/database/api/admin.py → containers/backend/api/admin.py Dosyayı Görüntüle


containers/database/api/apps.py → containers/backend/api/apps.py Dosyayı Görüntüle


containers/database/api/migrations/0001_initial.py → containers/backend/api/migrations/0001_initial.py Dosyayı Görüntüle


containers/database/api/migrations/0002_password.py → containers/backend/api/migrations/0002_password.py Dosyayı Görüntüle


containers/database/api/migrations/0003_mv_entries_to_password.py → containers/backend/api/migrations/0003_mv_entries_to_password.py Dosyayı Görüntüle


containers/database/api/migrations/0004_remove_entries_password_info_models.py → containers/backend/api/migrations/0004_remove_entries_password_info_models.py Dosyayı Görüntüle


containers/database/api/migrations/0005_password_version.py → containers/backend/api/migrations/0005_password_version.py Dosyayı Görüntüle


containers/database/api/migrations/0006_change_default_password_profile.py → containers/backend/api/migrations/0006_change_default_password_profile.py Dosyayı Görüntüle


containers/database/api/migrations/__init__.py → containers/backend/api/migrations/__init__.py Dosyayı Görüntüle


containers/database/api/models.py → containers/backend/api/models.py Dosyayı Görüntüle


containers/database/api/permissions.py → containers/backend/api/permissions.py Dosyayı Görüntüle


containers/database/api/serializers.py → containers/backend/api/serializers.py Dosyayı Görüntüle


containers/database/api/tests/__init__.py → containers/backend/api/tests/__init__.py Dosyayı Görüntüle


containers/database/api/tests/factories.py → containers/backend/api/tests/factories.py Dosyayı Görüntüle


containers/database/api/tests/tests_passwords.py → containers/backend/api/tests/tests_passwords.py Dosyayı Görüntüle


containers/database/api/urls.py → containers/backend/api/urls.py Dosyayı Görüntüle


containers/database/api/views.py → containers/backend/api/views.py Dosyayı Görüntüle


+ 7
- 0
containers/backend/entrypoint.sh Dosyayı Görüntüle

@@ -0,0 +1,7 @@
#!/usr/bin/env bash

python3 manage.py migrate
python3 manage.py collectstatic --clear --no-input
python3 wait_db.py

exec "$@"

containers/database/lesspass/__init__.py → containers/backend/lesspass/__init__.py Dosyayı Görüntüle


containers/database/lesspass/settings.py → containers/backend/lesspass/settings.py Dosyayı Görüntüle

@@ -18,7 +18,7 @@ SECRET_KEY = env('SECRET_KEY', preprocessor=get_secret_key, default=None)

DEBUG = env.bool('DJANGO_DEBUG', default=False)

ALLOWED_HOSTS = env('ALLOWED_HOSTS', cast=list, default=['localhost', '127.0.0.1', '.lesspass.com'])
ALLOWED_HOSTS = env('ALLOWED_HOSTS', cast=list, default=['backend', '.lesspass.com'])

ADMINS = (('Guillaume Vincent', 'guillaume@oslab.fr'),)


containers/database/lesspass/urls.py → containers/backend/lesspass/urls.py Dosyayı Görüntüle


containers/database/lesspass/wsgi.py → containers/backend/lesspass/wsgi.py Dosyayı Görüntüle


containers/database/manage.py → containers/backend/manage.py Dosyayı Görüntüle


containers/database/requirements.txt → containers/backend/requirements.txt Dosyayı Görüntüle


+ 19
- 0
containers/backend/wait_db.py Dosyayı Görüntüle

@@ -0,0 +1,19 @@
#!/usr/bin/env python
import socket
import time
import os

host = os.environ.get('DATABASE_HOST', 'db')
port = int(os.environ.get('DATABASE_PORT', '5432'))

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
timeout = 15
while timeout != 0:
try:
s.connect((host, port))
s.close()
break
except socket.error as ex:
timeout -= 1
print('wait for db to start... (%s sec remaining)' % timeout)
time.sleep(1)

+ 0
- 13
containers/database/.travis.yml Dosyayı Görüntüle

@@ -1,13 +0,0 @@
dist: trusty
sudo: required
language: python
python:
- 3.5
addons:
postgresql: "9.5"
services:
- postgresql
env:
- DATABASE_ENGINE=django.db.backends.postgresql_psycopg2 DATABASE_NAME=postgres DATABASE_USER=postgres DATABASE_PASSWORD= DATABASE_HOST=localhost DATABASE_PORT=5432
install: pip install -r requirements.txt
script: python manage.py test

+ 0
- 19
containers/database/Dockerfile Dosyayı Görüntüle

@@ -1,19 +0,0 @@
FROM python:3.5-alpine

RUN apk add --no-cache supervisor netcat-openbsd postgresql-dev gcc python3-dev musl-dev

RUN mkdir /backend
WORKDIR /backend
COPY requirements.txt /backend/
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

COPY api/ /backend/api/
COPY lesspass/ /backend/lesspass/
COPY manage.py /backend/manage.py

COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

+ 0
- 24
containers/database/README.md Dosyayı Görüntüle

@@ -1,24 +0,0 @@
# LessPass backend

REST API used by [lesspass-pure](https://github.com/lesspass/pure) to store password profiles

* python 3
* django rest framework
* django rest framework jwt
* djoser
* postgresql
* gunicorn

## Tests

pip install -r requirements.txt
python manage.py test

## License

This project is licensed under the terms of the GNU GPLv3.


## Issues

report issues on [LessPass project](https://github.com/lesspass/lesspass/issues)

+ 0
- 8
containers/database/entrypoint.sh Dosyayı Görüntüle

@@ -1,8 +0,0 @@
#!/usr/bin/env bash

while ! nc -z db 5432; do sleep 3; done

python manage.py migrate
python manage.py collectstatic --clear --no-input

exec "$@"

+ 0
- 14
containers/database/supervisord.conf Dosyayı Görüntüle

@@ -1,14 +0,0 @@
[supervisord]
nodaemon=true
logfile=/dev/null
pidfile=/var/run/supervisord.pid

[program:gunicorn]
directory=/backend
command=gunicorn lesspass.wsgi:application -w 2 -b :8000
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

+ 18
- 2
containers/docker-compose.yml Dosyayı Görüntüle

@@ -1,11 +1,23 @@
version: "3"
services:
db:
image: postgres:9.5
volumes:
- postgresql:/var/lib/postgresql/data
backend:
build: ./backend
expose:
- '8000'
links:
- db
env_file:
- .env
profiles:
image: typesense/typesense:0.9.2
volumes:
- profiles:/data
ports:
- 8108:8108
expose:
- '8108'
environment:
API_KEY: dev-api-key
SEARCH_ONLY_API_KEY: dev-search-only-api-key
@@ -21,3 +33,7 @@ services:
volumes:
- ./webserver/ssl:/ssl
- ./webserver:/webserver
volumes:
postgresql:
www:
profiles:

+ 1
- 0
containers/webserver/.gitignore Dosyayı Görüntüle

@@ -0,0 +1 @@
ssl

+ 0
- 1
containers/webserver/generate_apache_conf.py Dosyayı Görüntüle

@@ -11,7 +11,6 @@ if __name__ == "__main__":
"SSL_CERTIFICATE_KEY_FILE": "/etc/httpd/ssl/private/%s.key" % fqdn,
"DEBUG": os.environ.get("DEBUG", "0") == "1",
}

print(context)
jinja_template = Template(open("/webserver/lesspass.conf.j2").read())
with open("/etc/httpd/conf.d/lesspass.conf", "w") as f:


+ 9
- 0
containers/webserver/lesspass.conf.j2 Dosyayı Görüntüle

@@ -9,6 +9,15 @@ ServerName {{ FQDN }}

<VirtualHost *:443>
ServerName www.{{ FQDN }}
ProxyPass /api/ http://backend:8000/api/
ProxyPassReverse /api/ http://backend:8000/api/
SSLEngine on
SSLCertificateFile {{ SSL_CERTIFICATE_FILE }}
SSLCertificateKeyFile {{ SSL_CERTIFICATE_KEY_FILE }}
</VirtualHost>

<VirtualHost *:443>
ServerName www.{{ FQDN }}
ServerAlias {{ FQDN }}
DocumentRoot /var/www/html


Yükleniyor…
İptal
Kaydet