viadee / docker-hub-rate-limit-exporter

Know your limits - Via Prometheus
MIT License
42 stars 15 forks source link

Make smaller docker image using multistage build #1

Closed petrjurasek closed 4 years ago

petrjurasek commented 4 years ago

Make docker image smaller

docker build -t petrjurasek/docker-hub-rate-limit-exporter .
Sending build context to Docker daemon  1.632MB
Step 1/11 : FROM python:3-alpine as build
 ---> bcab265f7997
Step 2/11 : WORKDIR /install
 ---> Using cache
 ---> 89841d543429
Step 3/11 : COPY ./requirements.txt /requirements.txt
 ---> Using cache
 ---> f11e405f8b7f
Step 4/11 : RUN pip install --prefix=/install -r /requirements.txt
 ---> Using cache
 ---> 969a9e782b6b
Step 5/11 : FROM python:3-alpine
 ---> bcab265f7997
Step 6/11 : WORKDIR /src
 ---> Using cache
 ---> 3beb98e81b4b
Step 7/11 : ENV PYTHONPATH '/src/'
 ---> Using cache
 ---> 14a599d0a5a7
Step 8/11 : COPY --from=build /install /usr/local
 ---> Using cache
 ---> 06518f027d2e
Step 9/11 : COPY ./collector.py /src
 ---> Using cache
 ---> 642997fc642e
Step 10/11 : EXPOSE 80/TCP
 ---> Using cache
 ---> 42b51bc779d4
Step 11/11 : ENTRYPOINT python /src/collector.py
 ---> Using cache
 ---> 46aaa0825397
Successfully built 46aaa0825397
Successfully tagged petrjurasek/docker-hub-rate-limit-exporter:latest
docker images | grep docker-hub-rate-limit-exporter
petrjurasek/docker-hub-rate-limit-exporter   latest              46aaa0825397        4 minutes ago       49MB
viadee/docker-hub-rate-limit-exporter        version-1.1         4f3514c373e1        28 hours ago        895MB
mstein11 commented 4 years ago

Thanks for contributing!

I'll look at it over the weekend. We also would need to create a new release/tag for the changes to take effect.

mstein11 commented 4 years ago

Looks good and is merged now!

Thanks!

petrjurasek commented 4 years ago

@mstein11 thanks for processing. I see that 1.2. tag was also created (thanks for that), however the image tagged in docker hub has same digest as version 1.1

image

mstein11 commented 3 years ago

@petrjurasek thanks for check on that. There was a slight mistake with tagging the right commit. I fixed it and now the correct Dockerfile is used for building the image. See attached screenshot

[

Bildschirmfoto 2020-11-30 um 12 00 31

](url)