Slim(toolkit): Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
I have a legacy python app which uses celery==3.1.26.post2 and the official image python:2.7.18-slim-buster.
When I run docker-slim --http-probe=false my/image it goes from ~180MB to ~49MB, that's cool. But there are some celery files missing, in my case /usr/local/lib/python2.7/site-packages/celery/worker/strategy.py. The app code is copied to /app/tasks.
Then I tried building an image using python:3.8.5-slim-buster. This time the code at /app/tasks is missing and /usr/local/lib/python3.8/site-packages/celery/worker (the whole directory) too. I guess this scenario fails because the app doesn't work on Python 3 due to import failures in the dependencies, but the missing app code really caught my eye, or maybe I missed something?
The Dockerfile goes like this:
ARG PYTHON_VERSION=2.7.18
FROM python:${PYTHON_VERSION}-slim-buster AS base
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
FROM base AS release
COPY tasks tasks
USER nobody
ENV PYTHONWARNINGS=ignore
ENV PYTHONUNBUFFERED=1
ENTRYPOINT ["celery", "worker", "--app=tasks", "--pool=eventlet"]
CMD ["--loglevel=INFO", "--concurrency=100"]
Thanks for opening the issue @snahor ! Do you have a simple celery app I can use to repro the condition? It's probably related how celery works in general...
I have a legacy python app which uses
celery==3.1.26.post2
and the official imagepython:2.7.18-slim-buster
.When I run
docker-slim --http-probe=false my/image
it goes from ~180MB to ~49MB, that's cool. But there are some celery files missing, in my case/usr/local/lib/python2.7/site-packages/celery/worker/strategy.py
. The app code is copied to/app/tasks
.Then I tried building an image using
python:3.8.5-slim-buster
. This time the code at/app/tasks
is missing and/usr/local/lib/python3.8/site-packages/celery/worker
(the whole directory) too. I guess this scenario fails because the app doesn't work on Python 3 due to import failures in the dependencies, but the missing app code really caught my eye, or maybe I missed something?The Dockerfile goes like this:
requirements.txt:
Version: