Skip to content

Commit

Permalink
reduce size of builder image. also move Dockerfiles from docker/ to i…
Browse files Browse the repository at this point in the history
…mage/
  • Loading branch information
Timur Aitov authored and taitov committed Oct 24, 2023
1 parent b219872 commit a806cb2
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 45 deletions.
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.git
demo
docker
build*
*/build*
image
build
build_*
3 changes: 2 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
- uses: actions/checkout@v3
- name: Build the yanetplatform/builder
run: |
cd docker
cd image
# todo
build-unittest:
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@
*.includes
*.cflags
*.cxxflags
build*/
build
build_*
*.gcno
*.orig*
.idea
__pycache__
.cproject
.project
.settings/
.pydevproject
report/
.*
2 changes: 1 addition & 1 deletion demo/qemu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ docker pull yanetplatform/yanet
> [!NOTE]
> Or build it yourself:
> ```
> docker build -f yanet.Dockerfile -t yanetplatform/yanet .
> docker build -f image/yanet/Dockerfile -t yanetplatform/yanet .
> ```
Build virtual machine image `build_vm/yanet.qcow2`:
Expand Down
2 changes: 0 additions & 2 deletions docker/Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions image/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
all:
docker build -f builder/Dockerfile -t yanetplatform/builder builder
docker build -f builder/Dockerfile.ubuntu18.04 -t yanetplatform/builder_ubuntu18.04 builder
docker build -f yanet/Dockerfile -t yanetplatform/yanet ../
docker build -f yanet/Dockerfile.ubuntu18.04 -t yanetplatform/yanet_ubuntu18.04 ../
docker build -f yanet-announcer/Dockerfile -t yanetplatform/yanet-announcer ../
29 changes: 19 additions & 10 deletions docker/builder.Dockerfile → image/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:22.04

FROM ubuntu:22.04 AS base

RUN apt-get update && apt-get upgrade -y

Expand Down Expand Up @@ -42,7 +41,7 @@ RUN cd dpdk && \

WORKDIR /project/dpdk
RUN mkdir build
RUN meson setup --prefix=/usr -D platform=generic -D cpu_instruction_set=corei7 -D disable_libs=flow_classify -D enable_driver_sdk=true -D disable_drivers=net/mlx4 -D tests=false build
RUN meson setup --prefix=/target -D platform=generic -D cpu_instruction_set=corei7 -D disable_libs=flow_classify -D enable_driver_sdk=true -D disable_drivers=net/mlx4 -D tests=false build
RUN meson compile -C build
RUN meson install -C build

Expand All @@ -52,8 +51,8 @@ ENV NLOHMANN_JSON_VERSION 3.11.2

WORKDIR /project
RUN curl -L https://github.com/nlohmann/json/releases/download/v${NLOHMANN_JSON_VERSION}/json.hpp -o json.hpp
RUN mkdir -p /usr/include/nlohmann && \
cp -v json.hpp /usr/include/nlohmann/
RUN mkdir -p /target/include/nlohmann && \
cp -v json.hpp /target/include/nlohmann/


# protobuf
Expand All @@ -65,17 +64,23 @@ RUN git clone -b v${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobu
WORKDIR /project/protobuf
RUN git submodule update --init --recursive
RUN ./autogen.sh && \
./configure --prefix=/usr
RUN make
./configure --prefix=/target
RUN make -j
RUN make install && \
ldconfig


WORKDIR /project
RUN rm -rf *

FROM ubuntu:22.04

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
meson \
ninja-build \
pkg-config \
git \
libnuma-dev \
libibverbs-dev \
libpcap-dev \
libsystemd-dev \
libyaml-cpp-dev \
libgtest-dev \
Expand All @@ -89,3 +94,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
devscripts \
debhelper \
dupload

COPY --from=base /target/ /usr/

WORKDIR /project
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM ubuntu:18.04

FROM ubuntu:18.04 AS base

RUN apt-get update && apt-get upgrade -y

Expand Down Expand Up @@ -45,7 +44,7 @@ RUN cd dpdk && \

WORKDIR /project/dpdk
RUN mkdir build
RUN meson setup --prefix=/usr -D platform=generic -D cpu_instruction_set=corei7 -D disable_libs=flow_classify -D enable_driver_sdk=true -D disable_drivers=net/mlx4 -D tests=false build
RUN meson setup --prefix=/target -D platform=generic -D cpu_instruction_set=corei7 -D disable_libs=flow_classify -D enable_driver_sdk=true -D disable_drivers=net/mlx4 -D tests=false build
RUN meson compile -C build
RUN meson install -C build

Expand All @@ -55,8 +54,8 @@ ENV NLOHMANN_JSON_VERSION 3.11.2

WORKDIR /project
RUN curl -L https://github.com/nlohmann/json/releases/download/v${NLOHMANN_JSON_VERSION}/json.hpp -o json.hpp
RUN mkdir -p /usr/include/nlohmann && \
cp -v json.hpp /usr/include/nlohmann/
RUN mkdir -p /target/include/nlohmann && \
cp -v json.hpp /target/include/nlohmann/


# protobuf
Expand All @@ -68,8 +67,8 @@ RUN git clone -b v${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobu
WORKDIR /project/protobuf
RUN git submodule update --init --recursive
RUN ./autogen.sh && \
./configure --prefix=/usr
RUN make
./configure --prefix=/target
RUN make -j
RUN make install && \
ldconfig

Expand All @@ -85,14 +84,20 @@ RUN mkdir bison && \
WORKDIR /project/bison
RUN ./configure --prefix=/usr
RUN make -j
RUN make install
RUN make prefix=/target install


WORKDIR /project
RUN rm -rf *

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
meson \
ninja-build \
pkg-config \
git \
libnuma-dev \
libibverbs-dev \
libpcap-dev \
libsystemd-dev \
libyaml-cpp-dev \
libgtest-dev \
Expand All @@ -103,4 +108,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
vim \
devscripts \
debhelper \
dupload
dupload \
python3-pip

RUN python3 -m pip install meson

COPY --from=base /target/ /usr/

WORKDIR /project
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions yanet.Dockerfile → image/yanet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3 \
iproute2

RUN mkdir -p /run/yanet

COPY --from=builder /target/bin/* /usr/bin/
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM yanetplatform/builder_ubuntu18.04 AS builder

ARG YANET_VERSION_MAJOR
ARG YANET_VERSION_MINOR
ARG YANET_VERSION_REVISION
ARG YANET_VERSION_HASH
ARG YANET_VERSION_CUSTOM
ARG YANET_VERSION_MAJOR=0
ARG YANET_VERSION_MINOR=0
ARG YANET_VERSION_REVISION=0
ARG YANET_VERSION_HASH=00000000
ARG YANET_VERSION_CUSTOM=develop

COPY . /project
RUN meson setup --prefix=/target \
-Dtarget=release \
-Dyanet_config=release,firewall,l3balancer \
-Dyanet_config=release,firewall,l3balancer,low_memory \
-Darch=corei7,broadwell,knl \
-Dversion_major=$YANET_VERSION_MAJOR \
-Dversion_minor=$YANET_VERSION_MINOR \
Expand All @@ -30,6 +30,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ibverbs-providers \
libibverbs-dev

RUN mkdir -p /run/yanet

COPY --from=builder /target/bin/* /usr/bin/

0 comments on commit a806cb2

Please sign in to comment.