Skip to content

Commit e39b12a

Browse files
committed
Flatten image layers and slightly reduce image size
1 parent b43d21f commit e39b12a

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

.buildkite/hooks/pre-command

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# vim: set ft=bash:
12
set -eu
23

34
TODAY=$(date +"%Y%m%d")
@@ -18,3 +19,5 @@ echo "Short SHA = \"${CONTAINER_SHORT_SHA}\""
1819
export CONTAINER_BRANCH_NAME=$(echo "$BUILDKITE_BRANCH" | sed -e 's/[\/:]/_/g')
1920
[ -n "$CONTAINER_BRANCH_NAME" ]
2021
echo "Safe branch name = \"${CONTAINER_BRANCH_NAME}\""
22+
23+
mkdir -p dist/

.buildkite/pipeline.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
agents:
2+
queue: private
3+
14
env:
25
BUILDKIT_INLINE_CACHE: 1
36
BUILDKIT_PROGRESS: plain
47
COMPOSE_DOCKER_CLI_BUILD: 1
58
DOCKER_BUILDKIT: 1
6-
7-
env:
89
IMAGE_NAME: "mysql-server"
910
REGISTRY: "997601596833.dkr.ecr.us-east-1.amazonaws.com"
1011
MAIN_BRANCH: "8.0"
@@ -16,7 +17,7 @@ steps:
1617
artifact_paths:
1718
- "dist/*.tar.gz"
1819
plugins:
19-
- docker-compose#v3.9.0:
20+
- docker-compose#v3.10.0:
2021
run: builder
2122

2223
- wait
@@ -30,7 +31,7 @@ steps:
3031
login: true
3132
- artifacts#v1.5.0:
3233
download: "dist/mysql-*.tar.gz"
33-
- docker-compose#v3.9.0:
34+
- docker-compose#v3.10.0:
3435
run: release
3536
push:
3637
- "release:${REGISTRY}/branch/${IMAGE_NAME}:${CONTAINER_SEMVER}-ps-${CONTAINER_SHORT_SHA}-${CONTAINER_BRANCH_NAME}"
@@ -44,7 +45,7 @@ steps:
4445
login: true
4546
- artifacts#v1.5.0:
4647
download: "dist/mysql-*.tar.gz"
47-
- docker-compose#v3.9.0:
48+
- docker-compose#v3.10.0:
4849
run: release
4950
push:
5051
- "release:${REGISTRY}/main/${IMAGE_NAME}:${CONTAINER_SEMVER}-ps-${CONTAINER_SHORT_SHA}"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ source_downloads
1818

1919
# Configuration files for Visual Studio Code
2020
.vscode/
21+
22+
dist/

Dockerfile.release

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
1+
# syntax = docker/dockerfile:1.2
2+
3+
# Since we can't strip-components with ADD, we'll need to manually extract it
4+
FROM debian:bullseye-slim as mysql-dist
5+
ARG MYSQL_VERSION=mysql-8.0.28-linux-x86_64
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
RUN apt-get update && \
10+
apt-get install -y \
11+
binutils
12+
13+
COPY ${MYSQL_VERSION}.tar.gz /dist/
14+
15+
RUN mkdir /dist/usr && \
16+
tar -xzvf /dist/${MYSQL_VERSION}.tar.gz -C /dist/usr --strip-components=1 && \
17+
rm -rf /dist/usr/mysql-test && \
18+
strip /dist/usr/bin/mysql* || true
19+
120
FROM debian:bullseye-slim
221

3-
RUN apt-get update && apt-get upgrade -y
22+
RUN adduser --disabled-password --no-create-home --gecos '' vitess --uid 999 && \
23+
mkdir /var/run/mysqld && \
24+
chown vitess.vitess /var/run/mysqld
25+
26+
# Do this before apt-get layer so that's never cached
27+
COPY --from=mysql-dist --chown=root:root /dist/usr /usr/
428

529
ENV DEBIAN_FRONTEND noninteractive
630

7-
RUN apt-get install -y \
31+
RUN apt-get update && apt-get upgrade -y && \
32+
apt-get install -y --no-install-recommends \
833
libaio1 \
934
libnuma1 \
1035
libtcmalloc-minimal4 \
11-
binutils \
1236
bzip2 \
1337
ca-certificates \
1438
dirmngr \
@@ -25,19 +49,7 @@ RUN apt-get install -y \
2549
sysstat \
2650
wget \
2751
curl \
28-
percona-toolkit
29-
30-
ADD dist/ /dist
31-
32-
RUN tar -xzvf /dist/mysql-8.0.28-linux-x86_64.tar.gz -C /usr --strip-components=1
33-
RUN strip /usr/bin/mysql* || true
34-
RUN cd /usr ; chown root.root $(tar tzf /dist/mysql-8.0.28-linux-x86_64.tar.gz | cut -d/ -f2-)
35-
RUN rm -rf /dist/*.tar.gz
36-
RUN apt-get remove -y binutils && apt-get autoremove -y
37-
RUN rm -rf /usr/mysql-test
38-
39-
RUN adduser --disabled-password --no-create-home --gecos '' vitess --uid 999
40-
RUN mkdir /var/run/mysqld
41-
RUN chown vitess.vitess /var/run/mysqld
52+
percona-toolkit \
53+
&& rm -rf /var/lib/apt/lists/*
4254

4355
USER vitess

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010

1111
release:
1212
build:
13-
context: ./
14-
dockerfile: Dockerfile.release
13+
context: ./dist
14+
dockerfile: ../Dockerfile.release
1515
environment:
1616
- BUILDKITE_BRANCH=${BUILDKITE_BRANCH}

0 commit comments

Comments
 (0)