FROM alpine:3.7

LABEL author=AleksanderPiotrowski

COPY ./image/repositories /etc/apk/repositories
COPY ./image/bin /usr/local/bin

RUN apk add --update postgresql-dev \
      gcc \
      python3-dev \
      musl-dev \
      py3-gunicorn \
      py3-pillow \
      libgcc \
      jpeg-dev \
      freetype-dev \
      zlib-dev \
      openjpeg-dev \
      tiff-dev \
      tk-dev \
      tcl-dev \
      g++ \
      bash \
      nginx \
      supervisor

RUN apk add --no-cache --virtual .crypto-rundeps --repository http://dl-cdn.alpinelinux.org/alpine/edge/main libressl2.7-libcrypto
RUN apk add --no-cache --virtual libcrypto1.1-1.1.1-r5@edge --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing gdal
RUN apk add --no-cache gdal-dev@testing

COPY ./requirements.txt ./
RUN pip3 install -r requirements.txt

RUN mkdir -p /log/gunicorn /log/nginx /log/crond

COPY . /app/

WORKDIR /app/src/

RUN python3 manage.py collectstatic

EXPOSE 8000

COPY image/etc/crontab.conf /srv/crontab.conf
RUN crontab /srv/crontab.conf && rm -rf /srv/crontab.conf

COPY image/etc/web.conf /etc/nginx/conf.d/web.conf

COPY image/etc/supervisor.ini /etc/supervisor/conf.d/supervisor.ini
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisor.ini"]

