multi stage build

This commit is contained in:
2020-02-12 15:56:29 +01:00
parent 7254e8900f
commit ae4b053b69
5 changed files with 218 additions and 26 deletions

View File

@ -1,10 +1,12 @@
# Private temp download stage
FROM ubuntu:18.04 as intermediate
ARG UI_MODE=cli
# Donwnload stage
FROM ubuntu:18.04 AS download
ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin
# Setup git
# Setup deps
RUN apt-get update && \
apt-get -y install git && \
apt-get -y install --no-install-recommends git openssh-client ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Setup key and server for proprietary code
@ -28,38 +30,58 @@ RUN git clone https://github.com/MOVE-II/move2radio.git && \
cd move2radio-prop/ldpc && git checkout 940e8f96ccae831c7d3ad6b9497710696cd7f324 && git reset --hard && cd ../.. && \
git clone git@${PROP_SERVER}:${PROP_DIR_SDR}/gr-ccsds.git move2radio-prop/gr-ccsds && \
cd move2radio-prop/gr-ccsds && git checkout 5777e4176fe381327fe6cf55b7ec0dfe3c63b3f6 && git reset --hard && cd ../..
RUN git clone git@${PROP_SERVER}:${PROP_DIR_SDR}/com_utilities.git move2radio-prop/com_utilities
# Build stage
FROM ubuntu:18.04
# Base stage with deps
FROM ubuntu:18.04 AS base-cli
ENV DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin
# Setup build deps
RUN apt-get update && \
apt-get -y install build-essential git cmake autoconf unzip libtool-bin pkgconf libssl-dev \
python2.7 python-pip python-mako socat libcppunit-dev swig uuid-dev libusb-1.0-0-dev \
python-mako python-numpy python-wxgtk3.0 python-sphinx python-cheetah libzmq3-dev \
libcomedi-dev libqt4-opengl-dev python-qt4 libqwt-dev libsdl1.2-dev python-gtk2 python-lxml python-sip-dev && \
apt-get -y install --no-install-recommends build-essential git cmake autoconf automake unzip libtool-bin pkgconf libssl-dev \
python2.7 python-pip libcppunit-dev swig uuid-dev libusb-1.0-0-dev \
python-mako libzmq3-dev libcomedi-dev python-sip-dev socat && \
rm -rf /var/lib/apt/lists/*
# Copy sources from download stage
COPY --from=intermediate /app /app
# Base stage with GUI deps
FROM base-cli as base-gui
# Setup grc and gui deps
RUN apt-get update && \
apt-get -y install --no-install-recommends python-numpy python-wxgtk3.0 python-cheetah libzmq3-dev \
libqt4-opengl-dev python-qt4 libqwt-dev python-gtk2 python-lxml && \
rm -rf /var/lib/apt/lists/*
# Build stage
FROM base-${UI_MODE} AS build
# Copy sources
COPY --from=download /app /app
# Build sources
WORKDIR /app/move2radio
COPY build/CMakeLists.txt /app/move2radio/CMakeLists.txt
ARG UI_MODE=cli
COPY build/CMakeLists.${UI_MODE}.txt /app/move2radio/CMakeLists.txt
RUN mkdir build && cd build && \
cmake -DAPPIMAGE=OFF -DCONDA_ENV=OFF -DLDPC_OFFLINE=ON -DGR_CCSDS_OFFLINE=ON -DOFFLINE_DEPENDENCY_PATH=/app/move2radio-prop .. && \
make move2radio
# Install binaries
COPY build/blocks/* /app/move2radio/build/prefix/usr/share/gnuradio/grc/blocks/
RUN chmod 644 /app/move2radio/build/prefix/usr/share/gnuradio/grc/blocks/*.xml && \
cp -a build/prefix/usr/. /usr/ && \
ldconfig
# Entrypoint
# Run stage
FROM base-${UI_MODE} AS run
# Copy sources from build stage
COPY --from=build /app/move2radio/build/prefix/usr /usr
# Install binaries
COPY build/blocks/* /usr/share/gnuradio/grc/blocks/
RUN chmod 644 /usr/share/gnuradio/grc/blocks/*.xml && \
ldconfig
COPY build/fakeserver/* /app/fakeserver/
COPY build/run.sh /app/run.sh
# Entrypoint
RUN chmod +x /app/run.sh
ENTRYPOINT ["/app/run.sh"]