Skip to content

Commit

Permalink
provide smaller docker images cleaning go sdk after their build (#126)
Browse files Browse the repository at this point in the history
* provide smaller docker images cleaning go sdk after ther build

* remove test to maintain go version
  • Loading branch information
wpjunior authored Jul 19, 2024
1 parent 0f60233 commit 3459563
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 46 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
18 changes: 0 additions & 18 deletions tests/go/tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,6 @@ load 'bats-assert-master/load'
unset GO_VERSION
}

@test "reuse installed Go version" {
export GO_VERSION=1.x
run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Installing Go ${latest} (closest match from \$GO_VERSION=1.x)"* ]]
[[ "$output" == *"Using Go version: go version ${latest} linux/amd64"* ]]

run go version
assert_success
[[ "$output" == *"${latest}"* ]]

run /var/lib/tsuru/deploy
assert_success
[[ "$output" == *"Using already installed Go ${latest} (closest match from \$GO_VERSION=1.x)"* ]]
[[ "$output" == *"Using Go version: go version ${latest} linux/amd64"* ]]

unset GO_VERSION
}

@test "test project rootmain default procfile" {
cp -a ./fixtures/rootmain/* ${CURRENT_DIR}/
Expand Down

0 comments on commit 3459563

Please sign in to comment.