Skip to content
Snippets Groups Projects
Commit a6ad8e03 authored by Oto Šťáva's avatar Oto Šťáva
Browse files

Merge branch 'split-dockerfile' into 'master'

Split Dockerfile to build and runtime phases to cut down image size

See merge request !95
parents 4d6f45ba 06c86a29
No related branches found
No related tags found
1 merge request!95Split Dockerfile to build and runtime phases to cut down image size
Pipeline #123260 passed
FROM ubuntu:22.04
ARG BASE_IMAGE=ubuntu:22.04
FROM $BASE_IMAGE AS runtime_base
MAINTAINER Petr Spacek <pspacek@isc.org>
ENV DEBIAN_FRONTEND=noninteractive
RUN \
apt-get update -qq && \
apt-get install -y -qqq software-properties-common && \
add-apt-repository -y ppa:dns-oarc/dnsjit && \
apt-get update -qq && \
apt-get install -y -qqq \
dnsjit \
dnsjit-dev \
python3 \
python3-pip \
tshark \
jq \
libnghttp2-dev \
luajit \
libuv1-dev \
make \
cmake \
ninja-build \
pkg-config \
git && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update -q
RUN apt-get upgrade -y -q
# required for PPA repo usage
RUN apt-get install -y -q -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 \
ca-certificates \
lsb-release
# avoid PGP; keyring download here would have dependency on TLS anyway
# and I don't want to hardcode PGP key ID here
RUN echo "deb [trusted=yes] https://ppa.launchpadcontent.net/dns-oarc/dnsjit/ubuntu `lsb_release -c -s` main" > /etc/apt/sources.list.d/dns-oarc.list
RUN apt-get update -q
# shotgun's runtime depedencies
RUN apt-get install -y -q -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 \
dnsjit \
libnghttp2-14 \
libuv1 \
python3 \
python3-pip
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
# separate image for build, will not be tagged at the end
FROM runtime_base AS build_stage
RUN apt-get install -y -q -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 \
cmake \
dnsjit-dev \
g++ \
gcc \
git \
jq \
libnghttp2-dev \
libuv1-dev \
ninja-build \
pkg-config \
tshark
COPY . /shotgun
RUN mkdir /shotgun/replay/dnssim/build
WORKDIR /shotgun/replay/dnssim/build
RUN cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja
RUN cmake --build .
RUN cmake --install .
# copy only installed artifacts, Shotgun repo and throw away everything else
FROM runtime_base AS installed
COPY --from=build_stage /usr/local /usr/local
COPY . /shotgun
WORKDIR /shotgun
ENV PATH="${PATH}:/shotgun"
RUN cd replay/dnssim && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -G Ninja && \
cmake --build . && \
cmake --install . && \
cd /shotgun
RUN pip3 install -r requirements.txt
# cleanup intended for docker build --squash
RUN rm -rf /shotgun/.git
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment