1
\$\begingroup\$

This is a Dockerfile which aims to create a complete environment for the bismon project. I have written it as an exercise and to make it easy for other users to begin with bismon.

FROM ubuntu:latest
MAINTAINER Niklas Rosencrantz ([email protected])
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install --yes software-properties-common
RUN apt-add-repository --yes --update ppa:ubuntu-toolchain-r/test
RUN apt-get update
RUN apt-get install --yes git
RUN apt-get install --yes gcc-snapshot
RUN apt-get install --yes build-essential make gcc-8 cmake
RUN apt-get install --yes ninja-build g++-8 gcc-8-plugin-dev libgccjit-8-dev libgtk-3-dev
RUN apt-get install --yes markdown indent astyle tardy texlive texlive-full hevea
RUN adduser --disabled-password --gecos '' newuser
USER newuser
WORKDIR /home/newuser
RUN git clone https://github.com/ianlancetaylor/libbacktrace.git
RUN cd libbacktrace; ./configure ; make
USER root
WORKDIR /home/newuser/libbacktrace
RUN make install
USER newuser
RUN cd; git clone https://github.com/davidmoreno/onion.git; cd onion; mkdir build; cd build; cmake ..; make
USER root
WORKDIR /home/newuser/onion/build
RUN make install; cp /usr/local/lib/libonion* /usr/lib; cp /usr/local/lib/libbacktrace* /usr/lib
USER newuser
RUN cd; git clone https://github.com/bstarynk/bismon.git; cd bismon; make; touch ~/passwords_BM; chmod u+rw,go-rwx ~/passwords_BM
WORKDIR /home/newuser/bismon
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

Combine as many RUN statements as possible to reduce the number of layers (and size of the image). Each RUN command makes a new layer.

For example,

RUN apt-get update && apt-get install --yes software-properties-common git gcc-snapshot

After these, you should clean the cache with apt-get autoremove && apt-get autoclean.

For example,

RUN apt-get update && apt-get install --yes software-properties-common git gcc-snapshot && apt-get autoremove && apt-get autoclean

This saves space on the image.

FROM ubuntu:latest is not best practice. Sometimes something works with FROM ubuntu:16.04, but not FROM ubuntu:18.04 (for example, software compatibility).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.