Skip to content

Commit

Permalink
Move out pkg installation from Dockerfile.e2e-test
Browse files Browse the repository at this point in the history
Packages in Dockerfile.e2e-test are architecture dependant,
and it's not easy to cross-compile such containers.
They will always present original architecture.
Therefore it's better to move it to runtime when architecture
is 100% match.

Signed-off-by: Elina Akhmanova <elinka@google.com>
  • Loading branch information
code-elinka committed May 11, 2023
1 parent 6b1b0d0 commit 5470f00
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
18 changes: 1 addition & 17 deletions Dockerfile.e2e-test
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,10 @@ FROM debian:11

#ARG_ARCH & ARG_BIN are replaces with sed in build/rules.mk
ADD bin/ARG_ARCH/ARG_BIN /ARG_BIN
COPY cmd/e2e-test/run.sh /run.sh

ARG CLOUD_SDK_VERSION="416.0.0"
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH

COPY cmd/e2e-test/run.sh /run.sh

# Get architecture for gcloud cli installation
RUN if [ "ARG_ARCH" = "amd64" ]; \
then echo -n "x86_64" > /tmp/arch; \
else echo -n "arm" > /tmp/arch; fi;

# Download Google Cloud GPG and install google-cloud-cli
# See recommended instructions:
# cloud.google.com/sdk/docs/install#installation_instructions
RUN ARCH=`cat /tmp/arch` && \
apt-get update && \
apt-get install -y curl python apt-transport-https ca-certificates gnupg && \
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
tar xvf google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
rm google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz

ENTRYPOINT ["/run.sh"]
17 changes: 15 additions & 2 deletions cmd/e2e-test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@

# run.sh manages the settings required for running containerized in a
# Kubernetes cluster.
echo '--- BEGIN ---'

echo "Downloading test dependencies.."
CLOUDSDK_VERSION=${CLOUD_SDK_VERSION:-"416.0.0-0"}
apt-get update
apt-get install -y curl python apt-transport-https ca-certificates gnupg
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \
http://packages.cloud.google.com/apt cloud-sdk main" | \
tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | \
apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
apt-get update -y
apt-get install google-cloud-cli=$CLOUD_SDK_VERSION -y

echo '--- TESTING BEGINS ---'

for ATTEMPT in $(seq 60); do
PROJECT=$(curl -H'Metadata-Flavor:Google' metadata.google.internal/computeMetadata/v1/project/project-id 2>/dev/null)
Expand Down Expand Up @@ -126,4 +139,4 @@ fi

echo ==============================================================================
echo "RESULT: $RESULT"
echo '--- END ---'
echo '--- TESTING ENDS ---'

0 comments on commit 5470f00

Please sign in to comment.