From db0ab230636fb7602227b5b05426cfac43f0f3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Thu, 18 Jun 2020 18:02:02 +0300 Subject: [PATCH 1/9] WIP dockerization --- game_project/Dockerfile | 17 +++++++++++++++++ game_project/docker-compose.yaml | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 game_project/Dockerfile create mode 100644 game_project/docker-compose.yaml diff --git a/game_project/Dockerfile b/game_project/Dockerfile new file mode 100644 index 0000000..09cc95b --- /dev/null +++ b/game_project/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3 + +ENV PYTHONUNBUFFERED 1 + +RUN mkdir /game_project + +WORKDIR /game_project + +COPY requirements.txt /game_project/ + +RUN pip install -r requirements.txt + +COPY . /game_project/ + +# RUN python manage.py migrate + +# RUN python manage.py createsuperuser \ No newline at end of file diff --git a/game_project/docker-compose.yaml b/game_project/docker-compose.yaml new file mode 100644 index 0000000..aaa21e2 --- /dev/null +++ b/game_project/docker-compose.yaml @@ -0,0 +1,17 @@ +version: '3' +services: + db: + image: postgres + environment: + - POSTGRES_DB=postgres + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - .:/game_project + ports: + - "8000:8000" + depends_on: + - db \ No newline at end of file From 24dc2c6a34c3c0aa1540a0c067009358d99edb14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Sun, 21 Jun 2020 12:44:17 +0300 Subject: [PATCH 2/9] trying to minimize requirements.txt for the game --- game_project/requirements.txt | 92 +++++++++++++++++------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/game_project/requirements.txt b/game_project/requirements.txt index 1aa2ff5..1bbb0e8 100644 --- a/game_project/requirements.txt +++ b/game_project/requirements.txt @@ -1,49 +1,49 @@ -asgiref==3.2.7 -boto==2.49.0 -boto3==1.13.11 -botocore==1.16.11 -bpemb==0.3.0 -certifi==2020.4.5.1 -chardet==3.0.4 -cloudpickle==1.4.1 -cycler==0.10.0 -decorator==4.4.2 -Deprecated==1.2.10 +# asgiref==3.2.7 +# boto==2.49.0 +# boto3==1.13.11 +# botocore==1.16.11 +# bpemb==0.3.0 +# certifi==2020.4.5.1 +# chardet==3.0.4 +# cloudpickle==1.4.1 +# cycler==0.10.0 +# decorator==4.4.2 +# Deprecated==1.2.10 Django==3.0.5 django-crispy-forms==1.9.0 -docutils==0.15.2 +# docutils==0.15.2 flair==0.4.1 -future==0.18.2 -gensim==3.8.3 -hyperopt==0.2.4 -idna==2.9 -jmespath==0.10.0 -joblib==0.15.1 -kiwisolver==1.2.0 -matplotlib==3.2.1 -mpld3==0.3 -networkx==2.4 -numpy==1.18.4 -Pillow==7.1.1 -psutil==5.7.0 -pyparsing==2.4.7 -python-dateutil==2.8.1 -pytorch-pretrained-bert==0.6.2 -pytz==2019.3 -regex==2018.1.10 -requests==2.23.0 -s3transfer==0.3.3 -scikit-learn==0.23.0 -scipy==1.4.1 -segtok==1.5.10 -sentencepiece==0.1.90 -six==1.14.0 -sklearn==0.0 -smart-open==2.0.0 -sqlitedict==1.6.0 -sqlparse==0.3.1 -threadpoolctl==2.0.0 -torch==1.1.0 -tqdm==4.46.0 -urllib3==1.25.9 -wrapt==1.12.1 +# future==0.18.2 +# gensim==3.8.3 +# hyperopt==0.2.4 +# idna==2.9 +# jmespath==0.10.0 +# joblib==0.15.1 +# kiwisolver==1.2.0 +# matplotlib==3.2.1 +# mpld3==0.3 +# networkx==2.4 +# numpy==1.18.4 +# Pillow==7.1.1 +# psutil==5.7.0 +# pyparsing==2.4.7 +# python-dateutil==2.8.1 +# pytorch-pretrained-bert==0.6.2 +# pytz==2019.3 +# regex==2018.1.10 +# requests==2.23.0 +# s3transfer==0.3.3 +# scikit-learn==0.23.0 +# scipy==1.4.1 +# segtok==1.5.10 +# sentencepiece==0.1.90 +# six==1.14.0 +# sklearn==0.0 +# smart-open==2.0.0 +# sqlitedict==1.6.0 +# sqlparse==0.3.1 +# threadpoolctl==2.0.0 +torch>=1.1.0 +# tqdm==4.46.0 +# urllib3==1.25.9 +# wrapt==1.12.1 From 6864e38cd0dca419aed983b9dbbefd1ff964ec8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Sun, 21 Jun 2020 13:20:14 +0300 Subject: [PATCH 3/9] trying to minimize and refactor requirements.txt for the game --- game_project/Dockerfile | 6 ++++-- game_project/requirements-phase1.txt | 1 + game_project/{requirements.txt => requirements-phase2.txt} | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 game_project/requirements-phase1.txt rename game_project/{requirements.txt => requirements-phase2.txt} (96%) diff --git a/game_project/Dockerfile b/game_project/Dockerfile index 09cc95b..ecf0db3 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -6,9 +6,11 @@ RUN mkdir /game_project WORKDIR /game_project -COPY requirements.txt /game_project/ +COPY requirements-phase2.txt /game_project/ -RUN pip install -r requirements.txt +RUN pip install -r requirements-phase1.txt + +RUN pip install -r requirements-phase2.txt COPY . /game_project/ diff --git a/game_project/requirements-phase1.txt b/game_project/requirements-phase1.txt new file mode 100644 index 0000000..328053c --- /dev/null +++ b/game_project/requirements-phase1.txt @@ -0,0 +1 @@ +torch>=1.1.0 \ No newline at end of file diff --git a/game_project/requirements.txt b/game_project/requirements-phase2.txt similarity index 96% rename from game_project/requirements.txt rename to game_project/requirements-phase2.txt index 1bbb0e8..c9e35cd 100644 --- a/game_project/requirements.txt +++ b/game_project/requirements-phase2.txt @@ -24,7 +24,7 @@ flair==0.4.1 # mpld3==0.3 # networkx==2.4 # numpy==1.18.4 -# Pillow==7.1.1 +Pillow==7.1.1 # psutil==5.7.0 # pyparsing==2.4.7 # python-dateutil==2.8.1 @@ -43,7 +43,6 @@ flair==0.4.1 # sqlitedict==1.6.0 # sqlparse==0.3.1 # threadpoolctl==2.0.0 -torch>=1.1.0 # tqdm==4.46.0 # urllib3==1.25.9 # wrapt==1.12.1 From 901eea8af1bcf54847fde2a45085db1275e36267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Sun, 21 Jun 2020 13:21:27 +0300 Subject: [PATCH 4/9] fix in Dockerfile --- game_project/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/game_project/Dockerfile b/game_project/Dockerfile index ecf0db3..5ba75a5 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -6,6 +6,7 @@ RUN mkdir /game_project WORKDIR /game_project +COPY requirements-phase1.txt /game_project/ COPY requirements-phase2.txt /game_project/ RUN pip install -r requirements-phase1.txt From e9da2a6315c83fd7d271861d9945e87b2689bf79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Sun, 21 Jun 2020 13:43:52 +0300 Subject: [PATCH 5/9] static file problem and fix Dockerfile --- game_project/Dockerfile | 4 ++-- game_project/spellchecker/static/spellchecker/.placeholder | 0 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 game_project/spellchecker/static/spellchecker/.placeholder diff --git a/game_project/Dockerfile b/game_project/Dockerfile index 5ba75a5..206f889 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -6,6 +6,8 @@ RUN mkdir /game_project WORKDIR /game_project +COPY . /game_project/ + COPY requirements-phase1.txt /game_project/ COPY requirements-phase2.txt /game_project/ @@ -13,8 +15,6 @@ RUN pip install -r requirements-phase1.txt RUN pip install -r requirements-phase2.txt -COPY . /game_project/ - # RUN python manage.py migrate # RUN python manage.py createsuperuser \ No newline at end of file diff --git a/game_project/spellchecker/static/spellchecker/.placeholder b/game_project/spellchecker/static/spellchecker/.placeholder new file mode 100644 index 0000000..e69de29 From ef417f3405dfd5b6868648c24b4628ab985e51a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Sun, 21 Jun 2020 17:05:58 +0300 Subject: [PATCH 6/9] added migration to the Dockerfile --- game_project/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/game_project/Dockerfile b/game_project/Dockerfile index 206f889..ccaff25 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -15,6 +15,7 @@ RUN pip install -r requirements-phase1.txt RUN pip install -r requirements-phase2.txt -# RUN python manage.py migrate +RUN python manage.py migrate --noinput -# RUN python manage.py createsuperuser \ No newline at end of file +# RUN python manage.py createsuperuser +# Run with docker exec -it ${container_name} python manage.py createsuperuser \ No newline at end of file From 78bd7c52995a979eab89bdac3e43a10ac1be10b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Mon, 22 Jun 2020 21:41:13 +0300 Subject: [PATCH 7/9] kanarya_config.json is dockerized --- game_project/Dockerfile | 7 ++++--- game_project/game_project/settings.py | 4 +++- game_project/kanarya_config.json | 5 +++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 game_project/kanarya_config.json diff --git a/game_project/Dockerfile b/game_project/Dockerfile index ccaff25..e9ebe13 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -6,13 +6,14 @@ RUN mkdir /game_project WORKDIR /game_project -COPY . /game_project/ +COPY kanarya_config.json /etc/ COPY requirements-phase1.txt /game_project/ -COPY requirements-phase2.txt /game_project/ - RUN pip install -r requirements-phase1.txt +COPY . /game_project/ + +COPY requirements-phase2.txt /game_project/ RUN pip install -r requirements-phase2.txt RUN python manage.py migrate --noinput diff --git a/game_project/game_project/settings.py b/game_project/game_project/settings.py index 06ecced..c1b3639 100644 --- a/game_project/game_project/settings.py +++ b/game_project/game_project/settings.py @@ -14,7 +14,9 @@ import json from django.contrib.messages import constants as messages -with open('/etc/kanarya_config.json') as config_file: +config_filepath = '/etc/kanarya_config.json' + +with open(config_filepath) as config_file: config = json.load(config_file) # Build paths inside the project like this: os.path.join(BASE_DIR, ...) diff --git a/game_project/kanarya_config.json b/game_project/kanarya_config.json new file mode 100644 index 0000000..9a68218 --- /dev/null +++ b/game_project/kanarya_config.json @@ -0,0 +1,5 @@ +{ + "SECRET_KEY": "loremipsum", + "EMAIL_USER": "username", + "EMAIL_PASS": "password" +} \ No newline at end of file From 82a6ca3ed98359951e4a72382385e403fae4e0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Mon, 22 Jun 2020 21:48:38 +0300 Subject: [PATCH 8/9] Torch is expected to be updated infrequently. So it's installation is moved to the beginning. --- game_project/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/game_project/Dockerfile b/game_project/Dockerfile index e9ebe13..04241e2 100644 --- a/game_project/Dockerfile +++ b/game_project/Dockerfile @@ -6,11 +6,11 @@ RUN mkdir /game_project WORKDIR /game_project -COPY kanarya_config.json /etc/ - COPY requirements-phase1.txt /game_project/ RUN pip install -r requirements-phase1.txt +COPY kanarya_config.json /etc/ + COPY . /game_project/ COPY requirements-phase2.txt /game_project/ From 073277a3bb3b0b980a056cf13127fb835afef476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?onur=20gu=CC=88ngo=CC=88r?= Date: Thu, 30 Jul 2020 11:12:19 +0300 Subject: [PATCH 9/9] adding this for convenience --- game_project/requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 game_project/requirements.txt diff --git a/game_project/requirements.txt b/game_project/requirements.txt new file mode 100644 index 0000000..3b77b67 --- /dev/null +++ b/game_project/requirements.txt @@ -0,0 +1,4 @@ +Django==3.0.5 +django-crispy-forms==1.9.0 +flair==0.4.1 +Pillow==7.1.1 \ No newline at end of file