Skip to content

Commit a806cb2

Browse files
Timur Aitovtaitov
Timur Aitov
authored andcommitted
reduce size of builder image. also move Dockerfiles from docker/ to image/
1 parent b219872 commit a806cb2

File tree

12 files changed

+63
-45
lines changed

12 files changed

+63
-45
lines changed

Diff for: .dockerignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.git
22
demo
3-
docker
4-
build*
5-
*/build*
3+
image
4+
build
5+
build_*

Diff for: .github/workflows/docker-image.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
- uses: actions/checkout@v3
2727
- name: Build the yanetplatform/builder
2828
run: |
29-
cd docker
29+
cd image
30+
# todo
3031
3132
3233
build-unittest:

Diff for: .gitignore

+2-6
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
*.includes
66
*.cflags
77
*.cxxflags
8-
build*/
8+
build
9+
build_*
910
*.gcno
1011
*.orig*
11-
.idea
1212
__pycache__
13-
.cproject
14-
.project
15-
.settings/
16-
.pydevproject
1713
report/
1814
.*

Diff for: demo/qemu/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ docker pull yanetplatform/yanet
6464
> [!NOTE]
6565
> Or build it yourself:
6666
> ```
67-
> docker build -f yanet.Dockerfile -t yanetplatform/yanet .
67+
> docker build -f image/yanet/Dockerfile -t yanetplatform/yanet .
6868
> ```
6969
7070
Build virtual machine image `build_vm/yanet.qcow2`:

Diff for: docker/Makefile

-2
This file was deleted.

Diff for: image/Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
all:
2+
docker build -f builder/Dockerfile -t yanetplatform/builder builder
3+
docker build -f builder/Dockerfile.ubuntu18.04 -t yanetplatform/builder_ubuntu18.04 builder
4+
docker build -f yanet/Dockerfile -t yanetplatform/yanet ../
5+
docker build -f yanet/Dockerfile.ubuntu18.04 -t yanetplatform/yanet_ubuntu18.04 ../
6+
docker build -f yanet-announcer/Dockerfile -t yanetplatform/yanet-announcer ../

Diff for: docker/builder.Dockerfile renamed to image/builder/Dockerfile

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
FROM ubuntu:22.04
2-
1+
FROM ubuntu:22.04 AS base
32

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

@@ -42,7 +41,7 @@ RUN cd dpdk && \
4241

4342
WORKDIR /project/dpdk
4443
RUN mkdir build
45-
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
44+
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
4645
RUN meson compile -C build
4746
RUN meson install -C build
4847

@@ -52,8 +51,8 @@ ENV NLOHMANN_JSON_VERSION 3.11.2
5251

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

5857

5958
# protobuf
@@ -65,17 +64,23 @@ RUN git clone -b v${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobu
6564
WORKDIR /project/protobuf
6665
RUN git submodule update --init --recursive
6766
RUN ./autogen.sh && \
68-
./configure --prefix=/usr
69-
RUN make
67+
./configure --prefix=/target
68+
RUN make -j
7069
RUN make install && \
7170
ldconfig
7271

7372

74-
WORKDIR /project
75-
RUN rm -rf *
76-
73+
FROM ubuntu:22.04
7774

7875
RUN apt-get update && apt-get install -y --no-install-recommends \
76+
build-essential \
77+
meson \
78+
ninja-build \
79+
pkg-config \
80+
git \
81+
libnuma-dev \
82+
libibverbs-dev \
83+
libpcap-dev \
7984
libsystemd-dev \
8085
libyaml-cpp-dev \
8186
libgtest-dev \
@@ -89,3 +94,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
8994
devscripts \
9095
debhelper \
9196
dupload
97+
98+
COPY --from=base /target/ /usr/
99+
100+
WORKDIR /project

Diff for: docker/builder_ubuntu18.04.Dockerfile renamed to image/builder/Dockerfile.ubuntu18.04

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
FROM ubuntu:18.04
2-
1+
FROM ubuntu:18.04 AS base
32

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

@@ -45,7 +44,7 @@ RUN cd dpdk && \
4544

4645
WORKDIR /project/dpdk
4746
RUN mkdir build
48-
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
47+
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
4948
RUN meson compile -C build
5049
RUN meson install -C build
5150

@@ -55,8 +54,8 @@ ENV NLOHMANN_JSON_VERSION 3.11.2
5554

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

6160

6261
# protobuf
@@ -68,8 +67,8 @@ RUN git clone -b v${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobu
6867
WORKDIR /project/protobuf
6968
RUN git submodule update --init --recursive
7069
RUN ./autogen.sh && \
71-
./configure --prefix=/usr
72-
RUN make
70+
./configure --prefix=/target
71+
RUN make -j
7372
RUN make install && \
7473
ldconfig
7574

@@ -85,14 +84,20 @@ RUN mkdir bison && \
8584
WORKDIR /project/bison
8685
RUN ./configure --prefix=/usr
8786
RUN make -j
88-
RUN make install
87+
RUN make prefix=/target install
8988

9089

91-
WORKDIR /project
92-
RUN rm -rf *
93-
90+
FROM ubuntu:18.04
9491

9592
RUN apt-get update && apt-get install -y --no-install-recommends \
93+
build-essential \
94+
meson \
95+
ninja-build \
96+
pkg-config \
97+
git \
98+
libnuma-dev \
99+
libibverbs-dev \
100+
libpcap-dev \
96101
libsystemd-dev \
97102
libyaml-cpp-dev \
98103
libgtest-dev \
@@ -103,4 +108,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
103108
vim \
104109
devscripts \
105110
debhelper \
106-
dupload
111+
dupload \
112+
python3-pip
113+
114+
RUN python3 -m pip install meson
115+
116+
COPY --from=base /target/ /usr/
117+
118+
WORKDIR /project
File renamed without changes.
File renamed without changes.

Diff for: yanet.Dockerfile renamed to image/yanet/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2929
python3 \
3030
iproute2
3131

32-
RUN mkdir -p /run/yanet
33-
3432
COPY --from=builder /target/bin/* /usr/bin/

Diff for: docker/yanet_ubuntu18.04.Dockerfile renamed to image/yanet/Dockerfile.ubuntu18.04

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
FROM yanetplatform/builder_ubuntu18.04 AS builder
22

3-
ARG YANET_VERSION_MAJOR
4-
ARG YANET_VERSION_MINOR
5-
ARG YANET_VERSION_REVISION
6-
ARG YANET_VERSION_HASH
7-
ARG YANET_VERSION_CUSTOM
3+
ARG YANET_VERSION_MAJOR=0
4+
ARG YANET_VERSION_MINOR=0
5+
ARG YANET_VERSION_REVISION=0
6+
ARG YANET_VERSION_HASH=00000000
7+
ARG YANET_VERSION_CUSTOM=develop
88

99
COPY . /project
1010
RUN meson setup --prefix=/target \
1111
-Dtarget=release \
12-
-Dyanet_config=release,firewall,l3balancer \
12+
-Dyanet_config=release,firewall,l3balancer,low_memory \
1313
-Darch=corei7,broadwell,knl \
1414
-Dversion_major=$YANET_VERSION_MAJOR \
1515
-Dversion_minor=$YANET_VERSION_MINOR \
@@ -30,6 +30,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3030
ibverbs-providers \
3131
libibverbs-dev
3232

33-
RUN mkdir -p /run/yanet
34-
3533
COPY --from=builder /target/bin/* /usr/bin/

0 commit comments

Comments
 (0)