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 new file mode 100644 index 0000000..7a1bc55 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +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 +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