Skip to content

Commit

Permalink
provide smaller docker images cleaning go sdk after ther build
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Jul 19, 2024
1 parent 0f60233 commit 1b5390e
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions go/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,30 @@ if [[ ${version_to_install} == "" ]]; then
version_source="latest version"
fi

install_needed=1
if [[ -x ${GO_INSTALL_DIR}/bin/go ]]; then
current_version=$(${GO_INSTALL_DIR}/bin/go version)
if [[ "${current_version}" == *" ${version_to_install} "* ]]; then
echo "Using already installed Go ${version_to_install} (${version_source})"
install_needed=0
fi
fi

if [[ ${install_needed} == 1 ]]; then
echo "Installing Go ${version_to_install} (${version_source})"

rm -rf ${GO_INSTALL_DIR}
version_dir=${GO_INSTALL_DIR}_${version_to_install}
rm -rf ${version_dir}
mkdir -p ${version_dir}
download_url=${GO_DOWNLOAD_URL}/${version_to_install}.linux-amd64.tar.gz
if ! (curl -m 120 -sS --retry 3 -L "$download_url" | tar xz -C ${version_dir}); then
echo "ERROR: Unable to download Go from ${download_url}."
exit 1
fi
echo "Installing Go ${version_to_install} (${version_source})"

rm -rf ${version_dir}/api/ \
${version_dir}/blog/ \
${version_dir}/doc/ \
${version_dir}/test/ \
${version_dir}/lib/ \
${version_dir}/misc/
rm -rf ${GO_INSTALL_DIR}
version_dir=${GO_INSTALL_DIR}_${version_to_install}
rm -rf ${version_dir}
mkdir -p ${version_dir}
download_url=${GO_DOWNLOAD_URL}/${version_to_install}.linux-amd64.tar.gz

ln -s ${version_dir}/go ${GO_INSTALL_DIR}
hash -r
if ! (curl -m 120 -sS --retry 3 -L "$download_url" | tar xz -C ${version_dir}); then
echo "ERROR: Unable to download Go from ${download_url}."
exit 1
fi

rm -rf ${version_dir}/api/ \
${version_dir}/blog/ \
${version_dir}/doc/ \
${version_dir}/test/ \
${version_dir}/lib/ \
${version_dir}/misc/

ln -s ${version_dir}/go ${GO_INSTALL_DIR}
hash -r

echo "Using Go version: $(go version)"

if [ -z $(find ${APP_DIR}/current -name "*.go" -print -quit) ]; then
Expand Down Expand Up @@ -109,4 +100,9 @@ else
go install $GO_BUILD_VENDOR ./...
fi

go clean -cache
go clean -modcache

rm -rf ${GO_INSTALL_DIR}

popd >/dev/null 2>&1

0 comments on commit 1b5390e

Please sign in to comment.