question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

weightless docker image

See original GitHub issue

Description of Problem: rasa/rasa image is big (~1.3GB). I’m trying to shrink the image, would you be interested if the weight difference is important ?

Overview of the Solution: build requirements from scratch on an alpine image and remove non-necessary runtime system dependencies

Examples (if relevant):

Blockers (if relevant):

Definition of Done:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
tormath1commented, Jul 14, 2019

@wochinge, well I guess I won’t be harder than any dependencies. Actually, tf should release an Alpine wheel. 😅 Building dependencies from sources could optimize built wheels as we are compiling through GCC. I’ll let you know how’s going. Good work for your slim image. 👍

This is my first stage:

FROM python:3.7.3-alpine AS builder

RUN apk add --update \
        musl-dev \
        libffi-dev \
        freetype-dev \
        alpine-sdk \
        gfortran \
        perl \
        openjdk8 \
        zip \
        bash \
        git

# install openblas: numpy requirements
RUN wget https://github.com/xianyi/OpenBLAS/archive/v0.3.6.tar.gz \
        && tar -xf v0.3.6.tar.gz \
        && cd OpenBLAS-0.3.6/ \
        && make BINARY=64 FC=$(which gfortran) USE_THREAD=1 \
        && make PREFIX=/usr/lib/openblas install

# install bazel: tensorflow requirements
RUN wget https://github.com/bazelbuild/bazel/releases/download/0.28.0/bazel-0.28.0-dist.zip \
        && unzip bazel-0.28.0-dist.zip -d bazel \
        && cd bazel \
        && JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh \
        && mv output/bazel /usr/local/lib/

# patch numpy to use openblas
RUN pip download numpy==1.16.4 \
        && unzip numpy-1.16.4.zip \
        && cd numpy-1.16.4 \
        && echo -e '[DEFAULT]\n\
library_dirs = /usr/lib/openblas/lib\n\
include_dirs = /usr/lib/openblas/lib\n\n\
[atlas]\n\
atlas_libs = openblas\n\
libraries = openblas\n\n\
[openblas]\n\
libraries = openblas\n\
library_dirs = /usr/lib/openblas/lib\n\
include_dirs = /usr/lib/openblas/lib' \
        >> site.cfg \
        && python setup.py build --fcompiler=$(gfortran) \
        && python setup.py install

# install tensorflow
RUN git clone https://github.com/tensorflow/tensorflow.git \
        && cd tensorflow \
        && git checkout v1.13.1
# ./configure steps and install are missing

# fetch runtime dependencies
RUN scanelf --needed --nobanner --recursive /venv \
        | awk '{ gsub(/,/, "\nso:", $2); print "so: " $2 }' \
        | sort -u \
        | xargs -r apk info --installed \
        | sort -u \
        >> runtime.txt
1reaction
wochingecommented, Jul 13, 2019

@tormath1 Thanks for your offer! Could you please also check with https://github.com/RasaHQ/rasa/pull/3332 ? In this pr I’m trying to achieve the same 😃 Let me know if you have suggestions!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lightweight Docker Images in 5 Steps - Semaphore CI
Lightweight Docker Images Speed Up Deployment. Deploying your services packaged in lightweight Docker images has many practical benefits.
Read more >
Slimmer: Weight loss secrets for docker registries
Slimmer: Weight loss secrets for docker registries ... Containers are created from images which are stored in a Docker registry. An image consists...
Read more >
Docker good practices. "data" in a volume vs image - Stack Overflow
I'm imagining a Makefile that will build "data" image and APPS images. Is there any mechanism to check if the data has changed...
Read more >
Weightless lead boxes & AAMs - STALKER Anomaly - Mod DB
Makes the lead containers, AAMs, IAMs, LLMCs, basically weightless. Now with an experimental AR version.
Read more >
Docker for Beginner's | Showwcase
docker pull image-name i Pull the image from docker hub docker ps - List the container docker stop container-ID - Stop the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found