Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alpine image slimmed down to 25 MB #15

Open
tobwen opened this issue May 7, 2019 · 2 comments
Open

alpine image slimmed down to 25 MB #15

tobwen opened this issue May 7, 2019 · 2 comments

Comments

@tobwen
Copy link

tobwen commented May 7, 2019

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<atd.schubert@gmail.com>

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?

@atd-schubert
Copy link
Member

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

@justb4
Copy link

justb4 commented May 28, 2024

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants