docker-mapproxy icon indicating copy to clipboard operation
docker-mapproxy copied to clipboard

alpine image slimmed down to 25 MB

Open tobwen opened this issue 5 years ago • 2 comments

With the help of this, I was able to fix the lib c bug of Python's util, which will get fixed in v3.8 and causes trouble with Shapely. Sure, there might be a better patch than the Alpine one, but this one is working fine in this case.

My edit of this dockerfile isn't elegant, but it drops all the building dependencies (f.e. the huge libc & gcc stuff) and results in a small image of less than 30 MB:

FROM python:3.5-alpine
MAINTAINER Arne Schubert<[email protected]>

ARG MAPPROXY_VERSION=1.11.0

ENV MAPPROXY_VERSION $MAPPROXY_VERSION
ENV MAPPROXY_PROCESSES 4
ENV MAPPROXY_THREADS 2

RUN set -x \
  && printf "%s\n%s\n" '#!/bin/sh' 'if [ "$1" = "-p" ]; then echo "    libc.musl-x86_64.so.1 (libc6,x86-64) => /lib/libc.musl-x86_64.so.1"; exit 0; fi' > /tmp/ldconfig \
  && tail -n+2 /sbin/ldconfig >> /tmp/ldconfig \
  && mv /tmp/ldconfig /sbin/ldconfig \
  && chmod +x /sbin/ldconfig \ 
  && apk add --update --no-cache --virtual .build-deps-stable build-base linux-headers \
  && apk add --update --no-cache --virtual .build-deps-edge \
     --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
     --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
     gdal-dev proj4-dev geos-dev zlib-dev jpeg-dev \
  && adduser -h /mapproxy -s /bin/sh -D mapproxy \
  && pip install --upgrade pip \
  && pip install Shapely Pillow requests geojson uwsgi pyproj==1.9.6 boto3 MapProxy==$MAPPROXY_VERSION \
  && apk del .build-deps-stable .build-deps-edge \
  && runDeps="geos giflib libcrypto1.1 libcurl libgcc libjpeg-turbo libpng libpq libstdc++ musl sqlite-libs tiff zlib" \
  && apk add --no-cache --virtual .run-deps $runDeps \
     --repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
     --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
  && rm -Rf /root/* /root/.cache \
  && mkdir -p /docker-entrypoint-initmapproxy.d

COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["mapproxy"]

USER mapproxy
VOLUME ["/mapproxy"]
EXPOSE 8080
# Stats
EXPOSE 9191

Maybe would could just set the automatically installed packages on "hold", like the DPKG-way, to protect them from automatic removal?

tobwen avatar May 07 '19 02:05 tobwen

Sorry, I didn't see your issues, here. I will take a look at it on next weekend...

atd-schubert avatar Aug 14 '19 09:08 atd-schubert

In the meantime things progressed: Alpine is not the best choice these days. Now using "slim" Debian packages. Compressed size around 190MB.

Edit: refering to fork of this repo: https://github.com/justb4/docker-mapproxy .

justb4 avatar May 28 '24 22:05 justb4