From 5262a24c8389ce868f06c5c0405cd128e701cb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boss=C3=A1nyi=20Tibor?= Date: Thu, 23 Jul 2020 22:57:31 +0200 Subject: [PATCH] production fix url, settings.prod, docker fileswq --- .key | 3 +++ Dockerfile | 16 ++++++++++++++++ docker-compose.sh | 2 ++ docker-compose.yml | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 13 +++++++++++++ uwsgi_params | 13 +++++++++++++ 6 files changed, 83 insertions(+) create mode 100644 .key create mode 100644 Dockerfile create mode 100755 docker-compose.sh create mode 100644 docker-compose.yml create mode 100644 requirements.txt create mode 100644 uwsgi_params diff --git a/.key b/.key new file mode 100644 index 0000000..718bbd4 --- /dev/null +++ b/.key @@ -0,0 +1,3 @@ +DJANGO_SETTINGS_MODULE=aitrainer_backoffice/aitrainer_backoffice/settings/prod.py +MYSQL_ROOT_PASSWORD=andio2009 +MYSQL_USER=root \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..565f331 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.7 +WORKDIR /aitrainer_backoffice +ADD . /aitrainer_backoffice/ +RUN apt-get update && apt-get install vim -y +RUN pip3 install uwsgi +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY uwsgi_params /var/www/aitrainer.info/ +COPY .key ./ +#ENV DJANGO_KEY=45u49283495j2435294234 +ENV DJANGO_SETTINGS_MODULE=aitrainer_backoffice/aitrainer_backoffice/settings/prod.py + + +ENV PORT=8000 +EXPOSE 8000 diff --git a/docker-compose.sh b/docker-compose.sh new file mode 100755 index 0000000..dc396e0 --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1,2 @@ +export $(cat .key | xargs) +docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b8addb4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3.7" +services: + web: + build: . + container_name: backoffice + volumes: + - .:/aitrainer_backoffice + - media:/aitrainer_backoffice/aitrainer_backoffice/media + depends_on: + - mysql-server + ports: + - "8002:8000" + command: gunicorn aitrainer_backoffice.aitrainer_backoffice.wsgi --env DJANGO_SETTINGS_MODULE=aitrainer_backoffice.aitrainer_backoffice.settings.prod --bind 0.0.0.0:8000 --workers 3 + + mysql-server: + image: mysql:8.0.20 + restart: always + environment: + MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD + volumes: + - mysql-data-backoffice:/var/lib/mysql + ports: + - "33060:3306" + + phpmyadmin: + image: phpmyadmin/phpmyadmin:latest + restart: always + environment: + PMA_HOST: mysql-server + PMA_USER: $MYSQL_USER + PMA_PASSWORD: $MYSQL_ROOT_PASSWORD + ports: + - "8085:80" +volumes: + mysql-data-backoffice: + media: diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..489ab8e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,13 @@ +django==3.0.8 +asgiref==3.2.10 +certifi==2020.6.20 +chardet==3.0.4 +idna==2.10 +pytz==2020.1 +sqlparse==0.3.1 +urllib3==1.25.9 +setuptools==49.2.0 +mysqlclient==2.0.1 +requests==2.24.0 +pillow==7.2.0 +gunicorn==20.0.4 \ No newline at end of file diff --git a/uwsgi_params b/uwsgi_params new file mode 100644 index 0000000..4f3b520 --- /dev/null +++ b/uwsgi_params @@ -0,0 +1,13 @@ +uwsgi_param QUERY_STRING $query_string; +uwsgi_param REQUEST_METHOD $request_method; +uwsgi_param CONTENT_TYPE $content_type; +uwsgi_param CONTENT_LENGTH $content_length; +uwsgi_param REQUEST_URI $request_uri; +uwsgi_param PATH_INFO $document_uri; +uwsgi_param DOCUMENT_ROOT $document_root; +uwsgi_param SERVER_PROTOCOL $server_protocol; +uwsgi_param REMOTE_ADDR $remote_addr; +uwsgi_param REMOTE_PORT $remote_port; +uwsgi_param SERVER_ADDR $server_addr; +uwsgi_param SERVER_PORT $server_port; +uwsgi_param SERVER_NAME $server_name; \ No newline at end of file