slimtoolkit / slim

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)
Apache License 2.0
19.45k stars 730 forks source link

Missing files #163

Open snahor opened 4 years ago

snahor commented 4 years ago

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"]

requirements.txt:

requests[security]==2.19.1
soundcloud==0.5.0
celery==3.1.26.post2
kombu==3.0.37
eventlet==0.24.1
python-json-logger==0.1.11
sentry-sdk==0.16.3
six==1.15.0

Version:

$ ./docker-slim --version
docker-slim version linux|Transformer|1.32.0|10b628fc3cd9f903237b9c31a6aba5ac4e6bc9c8|2020-08-24_06:14:32AM
kcq commented 4 years ago

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...