Skip to content

Commit

Permalink
chore: settings dockerfile for app, docs (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Apr 13, 2021
1 parent 77345b3 commit 605bb98
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 17 deletions.
75 changes: 70 additions & 5 deletions docker/app-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
75 changes: 70 additions & 5 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 7 additions & 7 deletions docker/docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
RUN pip install --force-reinstall -r /usr/src/requirements/docs.txt

0 comments on commit 605bb98

Please sign in to comment.