From 34595632106adb6f3c17bf149bc93e30cd7a3fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilson=20J=C3=BAnior?= Date: Fri, 19 Jul 2024 13:50:54 -0300 Subject: [PATCH] provide smaller docker images cleaning go sdk after their build (#126) * provide smaller docker images cleaning go sdk after ther build * remove test to maintain go version --- go/deploy | 52 +++++++++++++++++++++------------------------ tests/go/tests.bats | 18 ---------------- 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/go/deploy b/go/deploy index ff2f6f7..95c1cef 100755 --- a/go/deploy +++ b/go/deploy @@ -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 @@ -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 diff --git a/tests/go/tests.bats b/tests/go/tests.bats index 7e2b3ae..9f216eb 100644 --- a/tests/go/tests.bats +++ b/tests/go/tests.bats @@ -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}/