Dockerfile for C project 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 (niklasrosencrantz@xyz.com)
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
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 &amp;&amp; apt-get install --yes software-properties-common git gcc-snapshot


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

For example, 

RUN apt-get update &amp;&amp; apt-get install --yes software-properties-common git gcc-snapshot &amp;&amp; apt-get autoremove &amp;&amp; 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).