blob: 0f1fff9d35067e409256a994e86b103368bbad81 [file]
#!/usr/bin/env bash
set -e
# Copyright 2021 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
source private/devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
usage() {
>&2 cat <<EOUSAGE
Usage: $0 PROJECT_ID BUILD_TAG [GO_VERSION]
Build and push docker containers for the worker and frontend services.
Arguments:
PROJECT_ID GCP project ID where the built container images will be pushed.
BUILD_TAG Tag assigned to the resulting application container images
(gcr.io/\$PROJECT_ID/{frontend,worker}:\$BUILD_TAG). During Cloud
Build deployments, this is generated by deploy/prepare.sh.
GO_VERSION Official base Go Docker image tag (e.g. 1.26.4 for golang:1.26.4)
passed to Dockerfiles via --build-arg. If omitted, it will be
detected automatically from deploy-env.yaml.
Example:
$0 my-project-id 20260629t12-60f10bf-2ac5e23 1.26.4
$0 my-project-id 20260629t12-60f10bf-2ac5e23
EOUSAGE
exit 1
}
main() {
local project_id=$1
local build_tag=$2
local go_version=$3
if [[ -z $go_version ]]; then
go_version=$(get_go_version) || true
if [[ -z $go_version ]]; then
die "Failed to detect go_version from deploy/deploy-env.yaml. Please specify GO_VERSION explicitly."
fi
fi
for service in worker frontend
do
runcmd docker build -t gcr.io/$project_id/$service:$build_tag \
--build-arg GO_VERSION=$go_version \
-f private/config/Dockerfile.$service .
runcmd docker push gcr.io/$project_id/$service:$build_tag
done
}
main $@