Skip to content

Commit 99bdb67

Browse files
committed
feat docker: minimize the layers count and add ppa to the base
Before the changes: ``` REPOSITORY TAG IMAGE ID CREATED SIZE ghcr.io/userver-framework/ubuntu-22.04-userver-base-ci latest ff57d3b2fa34 3 hours ago 2.43GB ghcr.io/userver-framework/ubuntu-22.04-userver-base latest adfde06b0ce5 3 hours ago 1.07GB ``` After: ``` REPOSITORY TAG IMAGE ID CREATED SIZE ghcr.io/userver-framework/ubuntu-22.04-userver-base-ci latest 4de2e079395e 15 seconds ago 2.41GB ghcr.io/userver-framework/ubuntu-22.04-userver-base latest c44bd11fdcf6 About a minute ago 1.11GB ``` Tests: протестировано локально 0769691c730049dc5622bf92fdc36b8542e2fbcb
1 parent d3ef52d commit 99bdb67

File tree

9 files changed

+90
-177
lines changed

9 files changed

+90
-177
lines changed

.mapping.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,6 @@
26582658
"scripts/docker/base-ubuntu-22.04.dockerfile":"taxi/uservices/userver/scripts/docker/base-ubuntu-22.04.dockerfile",
26592659
"scripts/docker/core-ubuntu-20-gcc8/Dockerfile":"taxi/uservices/userver/scripts/docker/core-ubuntu-20-gcc8/Dockerfile",
26602660
"scripts/docker/core-ubuntu-20-gcc8/prepare_image.sh":"taxi/uservices/userver/scripts/docker/core-ubuntu-20-gcc8/prepare_image.sh",
2661-
"scripts/docker/install-additional-compilers-ubuntu-22.04.sh":"taxi/uservices/userver/scripts/docker/install-additional-compilers-ubuntu-22.04.sh",
26622661
"scripts/docker/pip-install.sh":"taxi/uservices/userver/scripts/docker/pip-install.sh",
26632662
"scripts/docker/setup-base-ubuntu-22.04-env.sh":"taxi/uservices/userver/scripts/docker/setup-base-ubuntu-22.04-env.sh",
26642663
"scripts/docs/README.md":"taxi/uservices/userver/scripts/docs/README.md",

scripts/docker/add_user.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
# Exit on any error
4-
set -eo pipefail
3+
# Exit on any error and treat unset variables as errors
4+
set -euo pipefail
55

66
DIR_UID="$(stat -c '%u' .)"
77
if [ "$DIR_UID" = "0" ]; then

scripts/docker/all-ubuntu-22-cl16/Dockerfile

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,8 @@ FROM ghcr.io/userver-framework/ubuntu-22.04-userver-base-ci:latest
44
# Set UTC timezone
55
ENV DEBIAN_FRONTEND noninteractive
66

7-
# install main packages
8-
RUN apt-get update && apt-get install -y --allow-unauthenticated \
9-
build-essential \
10-
binutils-dev \
11-
libmongoc-dev \
12-
libbson-dev \
13-
libpq-dev \
14-
postgresql-server-dev-all \
15-
libhiredis-dev \
16-
clang-format \
17-
clang-tidy \
18-
postgresql \
19-
python3-protobuf \
20-
python3-jinja2 \
21-
python3-venv \
22-
vim \
23-
redis-server
24-
25-
RUN apt-get clean all
26-
27-
28-
# add clickhouse repositories
29-
RUN sudo apt-get install -y apt-transport-https ca-certificates dirmngr
30-
RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754
31-
32-
RUN echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee \
33-
/etc/apt/sources.list.d/clickhouse.list
34-
35-
# add mongodb repositories
36-
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
37-
38-
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
39-
40-
RUN echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
41-
42-
RUN apt-get update && \
43-
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes && \
44-
apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -q -y --force-yes
45-
46-
RUN apt update && apt install libssl1.1
47-
48-
RUN apt-get install -y --allow-unauthenticated \
7+
RUN apt-get install -y \
8+
redis-server \
499
mongodb-org \
5010
mongodb-org-database \
5111
mongodb-org-server \
@@ -54,31 +14,9 @@ RUN apt-get install -y --allow-unauthenticated \
5414
mongodb-org-tools \
5515
postgresql-common \
5616
clickhouse-server \
57-
clickhouse-client
58-
59-
# add mariadb repositories
60-
RUN wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
61-
RUN chmod +x mariadb_repo_setup
62-
RUN ./mariadb_repo_setup
63-
64-
RUN apt-get install -y libmariadb-dev mariadb-server
17+
clickhouse-client \
18+
mariadb-server
6519

66-
# convoluted setup of rabbitmq + erlang taken from https://www.rabbitmq.com/install-debian.html#apt-quick-start-packagecloud
67-
## Team RabbitMQ's main signing key
68-
RUN curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
69-
## Launchpad PPA that provides modern Erlang releases
70-
RUN curl -1sLf "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg > /dev/null
71-
## PackageCloud RabbitMQ repository
72-
RUN curl -1sLf "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/io.packagecloud.rabbitmq.gpg > /dev/null
73-
## Add apt repositories maintained by Team RabbitMQ
74-
RUN printf "\
75-
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
76-
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
77-
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main \n\
78-
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main\n" \
79-
| sudo tee /etc/apt/sources.list.d/rabbitmq.list
80-
## Update package indices
81-
RUN sudo apt-get update -y
8220
## Install Erlang packages
8321
RUN sudo apt-get install -y erlang-base \
8422
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \

scripts/docker/all-ubuntu-22/Dockerfile

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,8 @@ FROM ghcr.io/userver-framework/ubuntu-22.04-userver-base:latest
44
# Set UTC timezone
55
ENV DEBIAN_FRONTEND noninteractive
66

7-
# install main packages
8-
RUN apt-get update && apt-get install -y --allow-unauthenticated \
9-
build-essential \
10-
binutils-dev \
11-
libmongoc-dev \
12-
libbson-dev \
13-
libpq-dev \
14-
postgresql-server-dev-all \
15-
libhiredis-dev \
16-
clang-format \
17-
clang-tidy \
18-
postgresql \
19-
python3-protobuf \
20-
python3-jinja2 \
21-
python3-venv \
22-
vim \
23-
redis-server
24-
25-
RUN apt-get clean all
26-
27-
28-
# add clickhouse repositories
29-
RUN sudo apt-get install -y apt-transport-https ca-certificates dirmngr
30-
RUN sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754
31-
32-
RUN echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee \
33-
/etc/apt/sources.list.d/clickhouse.list
34-
35-
# add mongodb repositories
36-
RUN wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
37-
38-
RUN echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
39-
40-
RUN echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
41-
42-
RUN apt-get update && \
43-
apt-get -o Dpkg::Options::="--force-confold" upgrade -q -y --force-yes && \
44-
apt-get -o Dpkg::Options::="--force-confold" dist-upgrade -q -y --force-yes
45-
46-
RUN apt update && apt install libssl1.1
47-
48-
RUN apt-get install -y --allow-unauthenticated \
7+
RUN apt-get install -y \
8+
redis-server \
499
mongodb-org \
5010
mongodb-org-database \
5111
mongodb-org-server \
@@ -54,31 +14,9 @@ RUN apt-get install -y --allow-unauthenticated \
5414
mongodb-org-tools \
5515
postgresql-common \
5616
clickhouse-server \
57-
clickhouse-client
58-
59-
# add mariadb repositories
60-
RUN wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
61-
RUN chmod +x mariadb_repo_setup
62-
RUN ./mariadb_repo_setup
63-
64-
RUN apt-get install -y libmariadb-dev mariadb-server
17+
clickhouse-client \
18+
mariadb-server
6519

66-
# convoluted setup of rabbitmq + erlang taken from https://www.rabbitmq.com/install-debian.html#apt-quick-start-packagecloud
67-
## Team RabbitMQ's main signing key
68-
RUN curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
69-
## Launchpad PPA that provides modern Erlang releases
70-
RUN curl -1sLf "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg > /dev/null
71-
## PackageCloud RabbitMQ repository
72-
RUN curl -1sLf "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/io.packagecloud.rabbitmq.gpg > /dev/null
73-
## Add apt repositories maintained by Team RabbitMQ
74-
RUN printf "\
75-
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
76-
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
77-
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main \n\
78-
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main\n" \
79-
| sudo tee /etc/apt/sources.list.d/rabbitmq.list
80-
## Update package indices
81-
RUN sudo apt-get update -y
8220
## Install Erlang packages
8321
RUN sudo apt-get install -y erlang-base \
8422
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
FROM ghcr.io/userver-framework/ubuntu-22.04-userver-base:latest
22

3-
COPY scripts/docker/install-additional-compilers-ubuntu-22.04.sh /userver_tmp/
4-
RUN (cd /userver_tmp && ./install-additional-compilers-ubuntu-22.04.sh)
5-
RUN rm -rf /userver_tmp
6-
7-
RUN DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends redis-server postgresql-14
8-
9-
# fix for porto layers
10-
RUN mkdir -p /place/berkanavt/ && DEBIAN_FRONTEND=noninteractive apt install -y fuse dupload libuv1 libuv1-dev
3+
# Fix for porto layers and install a bunch of compilers and databases
4+
RUN mkdir -p /place/berkanavt/ && \
5+
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
6+
fuse dupload libuv1 libuv1-dev \
7+
redis-server \
8+
postgresql-14 \
9+
clang-16 \
10+
lld-16 \
11+
clang-14 \
12+
lld-14 \
13+
g++-11 \
14+
gcc-11 \
15+
g++-13 \
16+
gcc-13

scripts/docker/base-ubuntu-22.04.dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ FROM ubuntu:22.04
33
COPY scripts/docs/en/deps/ubuntu-22.04.md /userver_tmp/
44
COPY scripts/docker/setup-base-ubuntu-22.04-env.sh /userver_tmp/
55
COPY scripts/docker/add_user.sh /userver_tmp/
6-
RUN (cd /userver_tmp && ./setup-base-ubuntu-22.04-env.sh && ./add_user.sh)
76

87
COPY scripts/external_deps/requirements.txt /userver_tmp/requirements/external-deps.txt
98
COPY scripts/grpc/requirements.txt /userver_tmp/requirements/grpc-userver.txt
@@ -18,9 +17,14 @@ COPY testsuite/requirements-net.txt /userver_tmp/requirements/net.txt
1817
COPY testsuite/requirements.txt /userver_tmp/requirements/testsuite-base.txt
1918

2019
COPY scripts/docker/pip-install.sh /userver_tmp/
21-
RUN (cd /userver_tmp && sudo -u user ./pip-install.sh)
2220

23-
RUN rm -rf /userver_tmp
21+
RUN ( \
22+
cd /userver_tmp \
23+
&& ./setup-base-ubuntu-22.04-env.sh \
24+
&& ./add_user.sh \
25+
&& sudo -u user ./pip-install.sh \
26+
&& rm -rf /userver_tmp \
27+
)
2428

2529
# add expose ports
2630
EXPOSE 8080-8100

scripts/docker/install-additional-compilers-ubuntu-22.04.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

scripts/docker/pip-install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
# Exit on any error
4-
set -eo pipefail
3+
# Exit on any error and treat unset variables as errors
4+
set -euo pipefail
55

66
for REQUIREMENT in requirements/*.txt; do
77
pip3 install -r ${REQUIREMENT}

scripts/docker/setup-base-ubuntu-22.04-env.sh

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,62 @@
11
#!/bin/bash
22

3-
# Exit on any error
4-
set -eo pipefail
3+
# Exit on any error and treat unset variables as errors
4+
set -euo pipefail
5+
6+
# Preparing to add new repos
7+
apt update
8+
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
9+
apt-transport-https ca-certificates dirmngr wget curl software-properties-common \
10+
gnupg gnupg2
11+
12+
gpg_retrieve() {
13+
# See https://unix.stackexchange.com/questions/682929/migrating-away-from-apt-key-adv
14+
# and https://github.com/llvm/llvm-project/issues/55784#issuecomment-1569643347
15+
curl -fsSL "$1" | gpg --dearmor -o "/usr/share/keyrings/$2.gpg"
16+
chmod a+r "/usr/share/keyrings/$2.gpg"
17+
}
18+
19+
20+
# Adding clang/llvm repos
21+
gpg_retrieve https://apt.llvm.org/llvm-snapshot.gpg.key llvm-snapshot
22+
printf "\
23+
deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main \n\
24+
deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main\n" > /etc/apt/sources.list.d/llvm.list
25+
26+
# Adding GCC repos
27+
add-apt-repository -y ppa:ubuntu-toolchain-r/test
28+
29+
# Adding clickhouse repositories as in https://clickhouse.com/docs/en/install#setup-the-debian-repository
30+
GNUPGHOME=$(mktemp -d)
31+
GNUPGHOME="$GNUPGHOME" gpg --no-default-keyring --keyring /usr/share/keyrings/clickhouse-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8919F6BD2B48D754
32+
rm -rf "$GNUPGHOME"
33+
chmod +r /usr/share/keyrings/clickhouse-keyring.gpg
34+
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb stable main" \
35+
| tee /etc/apt/sources.list.d/clickhouse.list
36+
37+
# Adding mariadb repositories (from https://www.linuxcapable.com/how-to-install-mariadb-on-ubuntu-linux/ )
38+
gpg_retrieve http://mirror.mariadb.org/PublicKey_v2 mariadb
39+
echo "deb [arch=amd64,arm64,ppc64el signed-by=/usr/share/keyrings/mariadb.gpg] http://mirror.mariadb.org/repo/10.11/ubuntu/ $(lsb_release -cs) main" \
40+
| tee /etc/apt/sources.list.d/mariadb.list
41+
42+
# convoluted setup of rabbitmq + erlang taken from https://www.rabbitmq.com/install-debian.html#apt-quick-start-packagecloud
43+
## Team RabbitMQ's main signing key
44+
gpg_retrieve https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA com.rabbitmq.team
45+
## Launchpad PPA that provides modern Erlang releases
46+
gpg_retrieve "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" net.launchpad.ppa.rabbitmq.erlang
47+
## PackageCloud RabbitMQ repository
48+
gpg_retrieve https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey io.packagecloud.rabbitmq
49+
## Add apt repositories maintained by Team RabbitMQ
50+
printf "\
51+
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
52+
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu focal main \n\
53+
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main \n\
54+
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ focal main\n" \
55+
| tee /etc/apt/sources.list.d/rabbitmq.list
56+
57+
gpg_retrieve https://www.mongodb.org/static/pgp/server-6.0.asc mongodb
58+
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" \
59+
| tee /etc/apt/sources.list.d/mongodb-org-6.0.list
560

661
# Install build dependencies
762
if [ ! -f ubuntu-22.04.md ]; then
@@ -26,12 +81,7 @@ apt update
2681
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
2782
${PACKAGES_TO_INSTALL} \
2883
chrpath \
29-
curl \
3084
sudo \
31-
gnupg \
32-
gnupg2 \
33-
wget \
34-
dirmngr \
3585
python3-pip \
3686
locales
3787

0 commit comments

Comments
 (0)