From 59f457b2d7a1f8ebab51d32f8adc60565148213a Mon Sep 17 00:00:00 2001 From: Pavlo Tkach <3469726+ptkach@users.noreply.github.com> Date: Mon, 13 Mar 2023 15:37:02 -0400 Subject: [PATCH] Use builder image as a base for schema-deployer and schema-verifier (#1955) --- release/builder/Dockerfile | 7 +++++++ release/builder/build.sh | 15 +++++++++++++-- release/cloudbuild-release.yaml | 4 ++-- release/schema-deployer/Dockerfile | 19 +++---------------- release/schema-verifier/Dockerfile | 29 +++-------------------------- 5 files changed, 28 insertions(+), 46 deletions(-) diff --git a/release/builder/Dockerfile b/release/builder/Dockerfile index 2fd7bb764..e3f3e4aca 100644 --- a/release/builder/Dockerfile +++ b/release/builder/Dockerfile @@ -29,6 +29,13 @@ RUN go build -o /cloudSchedulerDeployer FROM marketplace.gcr.io/google/debian10 ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 +# Add script for cloud scheduler deployer COPY --from=cloudSchedulerBuilder /cloudSchedulerDeployer /usr/local/bin/cloudSchedulerDeployer +# Add Cloud sql connector +ADD https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \ + /usr/local/bin/cloud_sql_proxy +RUN chmod +x /usr/local/bin/cloud_sql_proxy + ADD ./build.sh . RUN ["bash", "./build.sh"] + diff --git a/release/builder/build.sh b/release/builder/build.sh index 73c1402d0..512132fc5 100755 --- a/release/builder/build.sh +++ b/release/builder/build.sh @@ -40,9 +40,16 @@ apt-get install lsb-release -y export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO 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 add - +curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - +# Install pg_dump v11 (same as current server version). This needs to be +# downloaded from postgresql's own repo, because ubuntu1804 is too old. With a +# newer image 'apt-get install postgresql-client-11' may be sufficient. +curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - +sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \ + > /etc/apt/sources.list.d/pgdg.list' apt-get update -y +apt-get install postgresql-client-11 procps -y + apt-get install google-cloud-sdk-app-engine-java -y # Install git apt-get install git -y @@ -54,6 +61,10 @@ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb apt install ./google-chrome-stable_current_amd64.deb -y # Install libxss1 (needed by Karma) apt install libxss1 +# Use unzip to extract files from jars. +apt-get install zip -y +# Get netstat, used for checking Cloud SQL proxy readiness. +apt-get install net-tools apt-get remove apt-utils locales -y apt-get autoclean -y apt-get autoremove -y diff --git a/release/cloudbuild-release.yaml b/release/cloudbuild-release.yaml index 939f55276..5bae6a00f 100644 --- a/release/cloudbuild-release.yaml +++ b/release/cloudbuild-release.yaml @@ -107,7 +107,7 @@ steps: - -c - | set -e - docker build -t gcr.io/${PROJECT_ID}/schema_deployer:${TAG_NAME} . + docker build -t gcr.io/${PROJECT_ID}/schema_deployer:${TAG_NAME} --build-arg TAG_NAME=${TAG_NAME} --build-arg PROJECT_ID=${PROJECT_ID} . docker tag gcr.io/${PROJECT_ID}/schema_deployer:${TAG_NAME} \ gcr.io/${PROJECT_ID}/schema_deployer:latest docker push gcr.io/${PROJECT_ID}/schema_deployer:latest @@ -120,7 +120,7 @@ steps: - -c - | set -e - docker build -t gcr.io/${PROJECT_ID}/schema_verifier:${TAG_NAME} . + docker build -t gcr.io/${PROJECT_ID}/schema_verifier:${TAG_NAME} --build-arg TAG_NAME=${TAG_NAME} --build-arg PROJECT_ID=${PROJECT_ID} . docker tag gcr.io/${PROJECT_ID}/schema_verifier:${TAG_NAME} \ gcr.io/${PROJECT_ID}/schema_verifier:latest docker push gcr.io/${PROJECT_ID}/schema_verifier:latest diff --git a/release/schema-deployer/Dockerfile b/release/schema-deployer/Dockerfile index 3804ec982..623c6c2ae 100644 --- a/release/schema-deployer/Dockerfile +++ b/release/schema-deployer/Dockerfile @@ -23,24 +23,11 @@ # Although any Linux-based Java image with bash would work (e.g., openjdk:11), # as a GCP application we prefer to start with a GCP-approved base image. -FROM marketplace.gcr.io/google/debian10 -ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 -# Install openjdk-11 -RUN apt-get update -y \ - && apt-get install locales -y \ - && locale-gen en_US.UTF-8 \ - && apt-get install apt-utils -y \ - && apt-get upgrade -y \ - && apt-get install openjdk-11-jdk-headless curl procps -y - -# Get netstat, used for checking Cloud SQL proxy readiness. -RUN apt-get install net-tools +ARG PROJECT_ID +ARG TAG_NAME +FROM gcr.io/${PROJECT_ID}/builder:${TAG_NAME} COPY deploy_sql_schema.sh /usr/local/bin/ -ADD https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \ - /usr/local/bin/cloud_sql_proxy -RUN chmod +x /usr/local/bin/cloud_sql_proxy -# Adapted from https://github.com/flyway/flyway-docker/blob/master/Dockerfile RUN \ FLYWAY_MAVEN=https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline \ && FLYWAY_VERSION=$(curl ${FLYWAY_MAVEN}/maven-metadata.xml \ diff --git a/release/schema-verifier/Dockerfile b/release/schema-verifier/Dockerfile index 540a5c9ec..da64b09bd 100644 --- a/release/schema-verifier/Dockerfile +++ b/release/schema-verifier/Dockerfile @@ -21,34 +21,11 @@ # # Please refer to verify_deployed_sql_schema.sh for expected volumes and # arguments. - -FROM marketplace.gcr.io/google/debian10 -ENV DEBIAN_FRONTEND=noninteractive LANG=en_US.UTF-8 -# Install pg_dump v11 (same as current server version). This needs to be -# downloaded from postgresql's own repo, because ubuntu1804 is too old. With a -# newer image 'apt-get install postgresql-client-11' may be sufficient. -RUN apt-get update -y \ - && apt-get install locales -y \ - && locale-gen en_US.UTF-8 \ - && apt-get install curl gnupg lsb-release -y \ - && curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ - && sh -c \ - 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \ - > /etc/apt/sources.list.d/pgdg.list' \ - && apt-get update -y \ - && apt install postgresql-client-11 procps -y - -# Use unzip to extract files from jars. -RUN apt-get install zip -y - -# Get netstat, used for checking Cloud SQL proxy readiness. -RUN apt-get install net-tools +ARG PROJECT_ID +ARG TAG_NAME +FROM gcr.io/${PROJECT_ID}/builder:${TAG_NAME} COPY verify_deployed_sql_schema.sh /usr/local/bin/ COPY allowed_diffs.txt / -ADD https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \ - /usr/local/bin/cloud_sql_proxy -RUN chmod +x /usr/local/bin/cloud_sql_proxy - ENTRYPOINT [ "verify_deployed_sql_schema.sh" ]