From fb1562124bce5e32e52327d7f6bd78208aa6b429 Mon Sep 17 00:00:00 2001 From: Kyoungwon Lee Date: Mon, 9 Sep 2019 22:12:51 +0900 Subject: [PATCH 1/2] Add: initial commit for pokr.kr backend --- Dockerfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3918047 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM python:2 + +ENV PYTHONIOENCODING='UTF-8' +ENV LANG=en_US.UTF-8 +ENV LANGUAGE=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/* +RUN mkdir -p /pokr.kr && \ + mkdir ~/.pip && echo '[global]\n\ +index-url=http://mirror.kakao.com/pypi/simple/\n\ +trusted-host=mirror.kakao.com' > ~/.pip/pip.conf + +WORKDIR /pokr.kr +ADD . . +RUN pip install --upgrade pip && pip install -r requirements.txt && \ + pip install git+https://github.com/teampopong/popong-models.git && \ + pip install git+https://github.com/teampopong/popong-data-utils.git && \ + pip install git+https://github.com/teampopong/popong-nlp.git && \ + git submodule init && git submodule update + +ADD .conf.samples/alembic.ini.sample /pokr.kr/alembic.ini +ADD .conf.samples/settings.py.sample /pokr.kr/settings.py +#RUN cat /pokr.kr/.conf.samples/alembic.ini.sample | sed 's/ID_HERE/docker/g' | sed 's/PASSWD_HERE/docker/g' | sed 's/HOST_HERE/localhost/g' > ./pokr.kr/alembic.ini + +EXPOSE 8000 + +#VOLUME ["/data", "/tmp", "/share"] +CMD ["/bin/bash"] From 10ff50c8ee0c032975367651e5e2d06a4761907a Mon Sep 17 00:00:00 2001 From: Kyoungwon Lee Date: Mon, 9 Sep 2019 22:44:15 +0900 Subject: [PATCH 2/2] Add: some docker related files & config files --- .env.template | 5 ++++ Dockerfile | 4 +--- conf/nginx.conf | 0 docker-compose.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++++ entrypoint.sh | 3 +++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 .env.template create mode 100644 conf/nginx.conf create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh diff --git a/.env.template b/.env.template new file mode 100644 index 0000000..8232220 --- /dev/null +++ b/.env.template @@ -0,0 +1,5 @@ +DB_NAME= +DB_USER= +DB_PASSWORD= + +NGINX_SERVING_PORT= diff --git a/Dockerfile b/Dockerfile index 3918047..7a1bc55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,4 @@ ADD .conf.samples/settings.py.sample /pokr.kr/settings.py #RUN cat /pokr.kr/.conf.samples/alembic.ini.sample | sed 's/ID_HERE/docker/g' | sed 's/PASSWD_HERE/docker/g' | sed 's/HOST_HERE/localhost/g' > ./pokr.kr/alembic.ini EXPOSE 8000 - -#VOLUME ["/data", "/tmp", "/share"] -CMD ["/bin/bash"] +ENTRYPOINT ./entrypoint.sh diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d6aca30 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,58 @@ +version: '3' +services: + db: + image: postgres:11.3 + restart: always + container_name: pokr-db + ports: + - 5432:5432 + environment: + - PGDATA=/data/pgdata + - POSTGRES_DB=${DB_NAME} + - POSTGRES_USER=${DB_USER} + - POSTGRES_PASSWORD=${DB_PASSWORD} + + app: + container_name: pokr-app + build: . + volumes: + - /data:/data + - /tmp:/tmp + - /share:/share + - django-static:/django-static + environment: + - DJANGO_STATIC_ROOT=/django-static + depends_on: + - db + restart: always + logging: + driver: "json-file" + options: + max-size: "100k" + max-file: "10" + + nginx: + image: nginx:stable + container_name: pokr-nginx + restart: always + volumes: + - django-static:/django-static + - ./conf/nginx.conf:/etc/nginx/conf.d/pokr.conf + ports: + - ${NGINX_SERVING_PORT}:80 + command: + - /bin/bash + - -c + - | + rm -f /etc/nginx/conf.d/default.conf + nginx -g 'daemon off;' + depends_on: + - app + logging: + driver: "json-file" + options: + max-size: "100k" + max-file: "10" + +volumes: + django-static: diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..966d4d4 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/bin/bash