From 605bb988c0ae9d148a2510a3811a93f78054ee73 Mon Sep 17 00:00:00 2001 From: "@slovacus" Date: Tue, 21 Nov 2017 22:40:27 -0500 Subject: [PATCH] chore: settings dockerfile for app, docs (#106) --- docker/app-test/Dockerfile | 75 +++++++++++++++++++++++++++++++++++--- docker/app/Dockerfile | 75 +++++++++++++++++++++++++++++++++++--- docker/docs/Dockerfile | 14 +++---- 3 files changed, 147 insertions(+), 17 deletions(-) diff --git a/docker/app-test/Dockerfile b/docker/app-test/Dockerfile index d14f9a8..eafcb53 100644 --- a/docker/app-test/Dockerfile +++ b/docker/app-test/Dockerfile @@ -1,12 +1,77 @@ -FROM python:3.6.0 - +FROM python:3.6.1-alpine MAINTAINER Luis Mayta <@slovacus> +LABEL NAME python +LABEL VERSION 3.6.1 + +ENV PACKAGES nginx supervisor bash git libmagic +ENV PACKAGES_DEPENDENCES git \ + gcc \ + make \ + musl-dev \ + libc-dev \ + libmagic \ + gcc \ + zlib-dev \ + linux-headers \ + build-base \ + musl \ + musl-dev \ + build-base \ + openssl \ + pcre-dev +# By default, allow unlimited file sizes, modify it to limit the file sizes +# To have a maximum of 1 MB (Nginx's default) change the line to: +# ENV NGINX_MAX_UPLOAD 1m +ENV NGINX_MAX_UPLOAD 0 + COPY ./requirements/ /usr/src/requirements/ COPY ./requirements.txt /usr/src/requirements.txt -# set working directory to /app/ +RUN apk add --update --no-cache --virtual .build-deps \ + $PACKAGES_DEPENDENCES \ + && pip install --force-reinstall -r /usr/src/requirements/test.txt \ + && find /usr/local \ + \( -type d -a -name test -o -name tests \) \ + -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ + -exec rm -rf '{}' + \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .rundeps $runDeps \ + && apk del .build-deps \ + && apk add --update --no-cache $PACKAGES \ + # nginx + && mkdir -p /run/nginx \ + && mkdir -p /var/lib/nginx \ + && mkdir -p /var/lib/nginx/tmp \ + # forward request and error logs to docker log collector + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log \ + # Remove default configuration from Nginx + && rm -rf /etc/nginx/conf.d/default.conf + +# Copy the modified Nginx conf +COPY docker/templates/etc/nginx/nginx.conf /etc/nginx/nginx.conf +COPY docker/templates/etc/nginx/conf.d/nginx.conf /etc/nginx/conf.d/ +# Custom Supervisord config +COPY docker/templates/etc/supervisord.conf /etc/ +COPY docker/templates/etc/supervisor/conf.d/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +EXPOSE 80 + +# Copy the entrypoint that will generate Nginx additional configs +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + +# Add demo app +COPY ./ /usr/src WORKDIR /usr/src -# install python dependencies -RUN pip install -r /usr/src/requirements/test.txt +CMD ["/usr/bin/supervisord", "-n"] diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 8a309c7..4d02f32 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -1,12 +1,77 @@ -FROM python:3.6.0 - +FROM python:3.6.1-alpine MAINTAINER Luis Mayta <@slovacus> +LABEL NAME python +LABEL VERSION 3.6.1 + +ENV PACKAGES nginx supervisor bash git libmagic +ENV PACKAGES_DEPENDENCES git \ + gcc \ + make \ + musl-dev \ + libc-dev \ + libmagic \ + gcc \ + zlib-dev \ + linux-headers \ + build-base \ + musl \ + musl-dev \ + build-base \ + openssl \ + pcre-dev +# By default, allow unlimited file sizes, modify it to limit the file sizes +# To have a maximum of 1 MB (Nginx's default) change the line to: +# ENV NGINX_MAX_UPLOAD 1m +ENV NGINX_MAX_UPLOAD 0 + COPY ./requirements/ /usr/src/requirements/ COPY ./requirements.txt /usr/src/requirements.txt -# set working directory to /app/ +RUN apk add --update --no-cache --virtual .build-deps \ + $PACKAGES_DEPENDENCES \ + && pip install --force-reinstall -r /usr/src/requirements.txt \ + && find /usr/local \ + \( -type d -a -name test -o -name tests \) \ + -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \ + -exec rm -rf '{}' + \ + && runDeps="$( \ + scanelf --needed --nobanner --recursive /usr/local \ + | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \ + | sort -u \ + | xargs -r apk info --installed \ + | sort -u \ + )" \ + && apk add --virtual .rundeps $runDeps \ + && apk del .build-deps \ + && apk add --update --no-cache $PACKAGES \ + # nginx + && mkdir -p /run/nginx \ + && mkdir -p /var/lib/nginx \ + && mkdir -p /var/lib/nginx/tmp \ + # forward request and error logs to docker log collector + && ln -sf /dev/stdout /var/log/nginx/access.log \ + && ln -sf /dev/stderr /var/log/nginx/error.log \ + # Remove default configuration from Nginx + && rm -rf /etc/nginx/conf.d/default.conf + +# Copy the modified Nginx conf +COPY docker/templates/etc/nginx/nginx.conf /etc/nginx/nginx.conf +COPY docker/templates/etc/nginx/conf.d/nginx.conf /etc/nginx/conf.d/ +# Custom Supervisord config +COPY docker/templates/etc/supervisord.conf /etc/ +COPY docker/templates/etc/supervisor/conf.d/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +EXPOSE 80 + +# Copy the entrypoint that will generate Nginx additional configs +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] + +# Add demo app +COPY ./ /usr/src WORKDIR /usr/src -# install python dependencies -RUN pip install -r /usr/src/requirements/dev.txt +CMD ["/usr/bin/supervisord", "-n"] diff --git a/docker/docs/Dockerfile b/docker/docs/Dockerfile index c7b6b9e..d961b0f 100644 --- a/docker/docs/Dockerfile +++ b/docker/docs/Dockerfile @@ -1,14 +1,14 @@ FROM labpositiva/latex:3.6.1 MAINTAINER Luis Mayta <@slovacus> -COPY ./requirements/ /app/requirements/ -COPY ./requirements.txt /app/requirements.txt +LABEL NAME python +LABEL VERSION 3.6.1 -RUN apt-get update -y \ - && apt-get install -y build-essential +COPY ./requirements/ /usr/src/requirements/ +COPY ./requirements.txt /usr/src/requirements.txt -# set working directory to /app/ -WORKDIR /app +# set working directory to /usr/src +WORKDIR /usr/src # Install sphinx dependences -RUN pip install -r /app/requirements/docs.txt \ No newline at end of file +RUN pip install --force-reinstall -r /usr/src/requirements/docs.txt \ No newline at end of file