maxtortime
11/6/2017 - 1:54 PM

flask-docker-compose-example

flask-docker-compose-example

version: '2'

services:
    web:
        environment:
            - FLASK_CONFIG=production
        build: ./app/
        volumes:
            - .:/code
            - /var/uploads/
        command: gunicorn -w 2 -b :8000 manage:app
        depends_on:
            - redis
            - postgres
    redis:
        image: redis:alpine
        ports:
            - "6379:6379"
    data:
        image: postgres:alpine
        volumes:
            - /var/lib/postgresql
        command: "true"
    postgres:
        restart: always
        image: postgres:alpine
        volumes_from:
            - data
        ports:
            - "5432:5432"
    nginx:
        restart: always
        image: nginx:alpine
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - ./nginx.conf:/etc/nginx/nginx.conf
        volumes_from:
            - web
            - certbot
        links:
            - web:web
        depends_on:
            - certbot
        certbot:
            image: henridwyer/docker-letsencrypt-cron
            volumes:
                - /certs:/certs
            restart: always
            environment:
                - DOMAINS = example.com
                - EMAIL = EMAIL@EMAIL.COM
                - CONCAT = false
                - SEPARATE = false
FROM python:3.5-alpine

RUN apk add --no-cache build-base libffi-dev postgresql-dev

WORKDIR /code
ADD ./requirements.txt /code/requirements.txt
RUN pip install -r requirements.txt
ADD . /code