Skip to content

Commit

Permalink
PMM-12899 take the cache dir creation out of build-client-binary
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Mar 6, 2024
1 parent 32433e1 commit 34ddc26
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 61 deletions.
2 changes: 2 additions & 0 deletions build/docker/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ LABEL org.opencontainers.image.licenses Apache-2.0
LABEL org.opencontainers.image.title Percona Monitoring and Management Client
LABEL org.opencontainers.image.vendor Percona
LABEL org.opencontainers.image.version ${VERSION}
LABEL org.opencontainers.image.source https://github.com/percona/pmm/blob/main/build/docker/client/Dockerfile
LABEL org.opencontainers.image.docs https://docs.percona.com/percona-monitoring-and-management/setting-up/client/index.html#docker

COPY LICENSE /licenses/
COPY --from=users --chown=0:0 /etc/passwd /etc/passwd
Expand Down
2 changes: 2 additions & 0 deletions build/docker/server/Dockerfile.el9
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ LABEL org.opencontainers.image.licenses AGPL-3.0
LABEL org.opencontainers.image.title Percona Monitoring and Management
LABEL org.opencontainers.image.vendor Percona LLC
LABEL org.opencontainers.image.version ${VERSION}
LABEL org.opencontainers.image.source https://github.com/percona/pmm/blob/main/build/docker/server/Dockerfile.el9
LABEL org.opencontainers.image.docs https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html

EXPOSE 80 443

Expand Down
32 changes: 0 additions & 32 deletions build/docker/server/create_users.sh

This file was deleted.

24 changes: 17 additions & 7 deletions build/local/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,36 @@ fb_commit_sha=$(git rev-parse HEAD)
echo $fb_commit_sha > fbCommitSha

PATH_TO_SCRIPTS="sources/pmm/src/github.com/percona/pmm/build/scripts"
export RPMBUILD_DOCKER_IMAGE=perconalab/rpmbuild:ol9

# Reference test environment
# Local reference test environment
# CPU: 4 cores
# RAM: 16GB
# OS: Ubuntu 22.04.1 LTS

# Building client source and binary takes 1m51s

# Build client source
# Build client source: 4m39s without cache
"$PATH_TO_SCRIPTS/build-client-source"

# Build client binary
RPMBUILD_DOCKER_IMAGE=perconalab/rpmbuild:ol9 "$PATH_TO_SCRIPTS/build-client-binary"
"$PATH_TO_SCRIPTS/build-client-binary"

# Building client source rpm takes 32s
RPMBUILD_DOCKER_IMAGE=perconalab/rpmbuild:ol9 "$PATH_TO_SCRIPTS/build-client-srpm"
"$PATH_TO_SCRIPTS/build-client-srpm"

# Building client rpm takes 1m36s
RPMBUILD_DOCKER_IMAGE=perconalab/rpmbuild:ol9 "$PATH_TO_SCRIPTS/build-client-rpm"
"$PATH_TO_SCRIPTS/build-client-rpm"

# Building client docker image takes 17s
GIT_COMMIT=$(git rev-parse HEAD)
DOCKER_CLIENT_TAG=local/pmm-client:${GIT_COMMIT:0:8} "${PATH_TO_SCRIPTS}/build-client-docker"
DOCKER_CLIENT_TAG=local/pmm-client:${GIT_COMMIT:0:8} "$PATH_TO_SCRIPTS/build-client-docker"

# Building PMM CLient locally (non-CI, i.e. non-Jenkins)
# total time: 6m26s - build from scratch, no initial cache
# total time: 3m26s - subsequent build, using cache from prior builds


# Building PMM CLient in a CI environment, i.e. Jenkins running on AWS
# total time: 6m26s - build from scratch, no initial cache
# total time: ??? - subsequent build, using cache from prior builds

3 changes: 0 additions & 3 deletions build/scripts/build-client-binary
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ copy_component() {
}

main() {
test -d "${root_dir}/go-path" || mkdir -p "{root_dir}/go-path"
test -d "${root_dir}/go-build" || mkdir -p "{root_dir}/go-build"

extract_source_tarball

gobuild_component "vmagent" "" "github.com/VictoriaMetrics/VictoriaMetrics" "app/vmagent"
Expand Down
37 changes: 19 additions & 18 deletions build/scripts/build-client-source
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ set -o xtrace

prepare_tarball() {
local repo_name=$1
local git_dir
if [ $repo_name = 'pmm-submodules' ]; then
mkdir -p ${root_dir}/sources/${repo_name}
git_dir="${root_dir}/sources/${repo_name}"
mkdir -p "${git_dir}"
else
local git_dir=$(dirname $(find "${root_dir}/sources/${repo_name}" -name .git | head -1))
git_dir=$(dirname $(find "${root_dir}/sources/${repo_name}" -name .git | head -1))
fi
local commit=$(git -C "${git_dir}" rev-parse --short HEAD)
local tarball=${source_dir}/${repo_name}-${commit}.tar.gz
Expand All @@ -24,18 +25,20 @@ prepare_tarball() {

if [ -f "${tarball}" ]; then
echo ${tarball} already exists, skipping build
else
if [ ${repo_name} = 'pmm-submodules' ]; then
tar -C sources -zcf ${repo_name}-${commit}.tar.gz ${repo_name}
mv ${repo_name}-${commit}.tar.gz ${source_dir}/
else
git -C "${git_dir}" archive \
--format=tar.gz \
--prefix=${repo_name}-${commit}/ \
-o ${tarball} \
"${commit}"
fi
return
fi

if [ ${repo_name} = 'pmm-submodules' ]; then
tar -C sources -zcf ${repo_name}-${commit}.tar.gz ${repo_name}
mv ${repo_name}-${commit}.tar.gz ${source_dir}/
return
fi

git -C "${git_dir}" archive \
--format=tar.gz \
--prefix=${repo_name}-${commit}/ \
-o ${tarball} \
"${commit}"
}

prepare_vmagent_tarball() {
Expand All @@ -44,23 +47,21 @@ prepare_vmagent_tarball() {
local commit_short=${commit_hash::8}
local tarball=${source_dir}/${repo_name}-${commit_short}.tar.gz
local repo_var=$(
echo "${repo_name}_commit" \
| sed -e 's:-:_:g' \
| tr '[[:lower:]]' '[[:upper:]]'
echo "${repo_name}_commit" | sed -e 's:-:_:g' | tr '[[:lower:]]' '[[:upper:]]'
)
echo "${repo_var}=$commit_short" >> ${client_properties}

if [ -f "${tarball}" ]; then
echo ${tarball} already exists, skipping download
else
wget https://github.com/VictoriaMetrics/VictoriaMetrics/archive/${commit_hash}.tar.gz -O ${tarball}
curl -o ${tarball} -fSL https://github.com/VictoriaMetrics/VictoriaMetrics/archive/${commit_hash}.tar.gz
fi
}

main() {
rm -rf ${source_tarball}
mkdir -p ${source_dir}/ $(dirname ${source_tarball}) || :
echo "PMM_SUBMODULES_COMMIT=$(git rev-parse --short HEAD)" > ${client_properties}

prepare_vmagent_tarball
prepare_tarball pmm-submodules
prepare_tarball pmm
Expand Down
1 change: 0 additions & 1 deletion build/scripts/build-server-rpm-all
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ ${bin_dir}/build-server-rpm vmproxy pmm
${bin_dir}/build-server-rpm victoriametrics
${bin_dir}/build-server-rpm alertmanager
${bin_dir}/build-server-rpm grafana
# ${bin_dir}/build-server-rpm grafana-db-migrator

# vim: expandtab shiftwidth=4 tabstop=4

0 comments on commit 34ddc26

Please sign in to comment.