summaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorsyn <isaqtm@gmail.com>2020-03-16 22:17:48 +0300
committersyn <isaqtm@gmail.com>2020-03-16 22:17:48 +0300
commit977c7c38ff4196f43c4784308d81fd7e6a471511 (patch)
tree3e53843c181a60ec7d2b3b1d4dfdf4868859c3a7 /deploy
downloadblure-977c7c38ff4196f43c4784308d81fd7e6a471511.tar.gz
Init commit
Diffstat (limited to 'deploy')
-rw-r--r--deploy/Dockerfile.base12
-rw-r--r--deploy/Dockerfile.dev19
-rw-r--r--deploy/docker-compose.yml50
-rw-r--r--deploy/nginx.conf36
4 files changed, 117 insertions, 0 deletions
diff --git a/deploy/Dockerfile.base b/deploy/Dockerfile.base
new file mode 100644
index 0000000..3df944d
--- /dev/null
+++ b/deploy/Dockerfile.base
@@ -0,0 +1,12 @@
+FROM python:3-alpine
+
+RUN apk add gcc g++ musl-dev make bash python3-dev zlib-dev jpeg-dev
+
+# pip installations are slow, so separate them to cache
+RUN pip3 install sanic
+RUN pip3 install jinja2-sanic
+RUN pip3 install requests
+RUN pip3 install asyncpg
+RUN pip3 install Pillow
+
+CMD bash
diff --git a/deploy/Dockerfile.dev b/deploy/Dockerfile.dev
new file mode 100644
index 0000000..7fa7af0
--- /dev/null
+++ b/deploy/Dockerfile.dev
@@ -0,0 +1,19 @@
+FROM python:3-alpine
+
+RUN apk add gcc g++ musl-dev make bash python3-dev zlib-dev jpeg-dev
+
+# pip installations are slow, so separate them to cache
+RUN pip3 install sanic
+RUN pip3 install jinja2-sanic
+RUN pip3 install requests
+RUN pip3 install asyncpg
+RUN pip3 install Pillow
+
+
+RUN mkdir /usr/src/app
+
+WORKDIR /usr/src/app
+
+EXPOSE 80
+
+CMD ["python", "run.py"]
diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml
new file mode 100644
index 0000000..8774b81
--- /dev/null
+++ b/deploy/docker-compose.yml
@@ -0,0 +1,50 @@
+version: '3'
+services:
+ app:
+ container_name: app
+ build:
+ context: ./..
+ dockerfile: deploy/Dockerfile.dev
+ environment:
+ POSTGRES_USER: ${POSTGRES_USER:-postgres}
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
+ networks:
+ - ntwrk
+ depends_on:
+ - pg
+ - ngx
+ volumes:
+ - ./..:/usr/src/app
+ - ngx_img:/var/ngx_img
+ cap_add:
+ - SYS_PTRACE
+
+ pg:
+ container_name: pg
+ image: postgres:alpine
+ volumes:
+ - db_data:/var/lib/postgresql/data
+ networks:
+ - ntwrk
+ ports:
+ - 5432:5432
+ restart: always
+
+ ngx:
+ container_name: ngx
+ image: nginx:alpine
+ networks:
+ - ntwrk
+ ports:
+ - 4000:80
+ restart: always
+ volumes:
+ - ./nginx.conf:/etc/nginx/nginx.conf
+ - ngx_img:/var/ngx_img
+
+networks:
+ ntwrk:
+
+volumes:
+ db_data:
+ ngx_img:
diff --git a/deploy/nginx.conf b/deploy/nginx.conf
new file mode 100644
index 0000000..8befc43
--- /dev/null
+++ b/deploy/nginx.conf
@@ -0,0 +1,36 @@
+worker_processes 1;
+load_module modules/ngx_http_image_filter_module.so;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ sendfile on;
+ keepalive_timeout 65;
+
+ server {
+ client_max_body_size 200M; # FIXME
+ listen 80;
+ server_name localhost;
+
+ image_filter_buffer 100M;
+
+ location / {
+ proxy_pass http://app;
+ proxy_redirect off;
+
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+ add_header Cache-Control "no-cache, must-revalidate";
+ }
+
+ location /ngx_img/ {
+ internal;
+ root /var/;
+ # image_filter resize 512 512;
+ }
+ }
+}