Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

Commit dc27df7

Browse files
authored
feat: add --entrypoint to support buildpack-based images (#200)
1 parent ba0058e commit dc27df7

2 files changed

Lines changed: 50 additions & 5 deletions

File tree

app-engine-exec-wrapper/README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
This is a wrapper Docker image that sets up an environment similar to the
44
[Google App Engine Flexible Environment](https://cloud.google.com/appengine/docs/flexible/),
55
suitable for running scripts and maintenance tasks provided by an application
6-
deployed to App Engine. In particular, it ensures a suitable CloudSQL Proxy
6+
deployed to App Engine. In particular, it ensures a suitable Cloud SQL Proxy
77
is running in the environment.
88

99
Its driving use case is running production database migrations for Ruby on
10-
Rails applications, and we expect similar uses for other languasges and
11-
frameworks.
10+
Rails applications, but it is also useful for Django applications, and we
11+
expect similar uses for other languages and frameworks.
1212

1313
## Usage
1414

@@ -31,6 +31,43 @@ You can find the image path using `gcloud app versions describe`.
3131
Ruby developers may use the [appengine gem](https://rubygems.org/gems/appengine)
3232
for a convenient Rake-based interface.
3333

34+
## Usage for Cloud Run
35+
36+
This wrapper can also be used for applications deployed to Cloud Run by defining
37+
your image name in the arguments. It would typically be added after your image build and image push steps"
38+
39+
steps:
40+
...
41+
- name: "gcr.io/google-appengine/exec-wrapper"
42+
args: ["-i", "gcr.io/my-project/my-image",
43+
...]
44+
45+
46+
If the Cloud Run image is built with [Google Cloud Buildpacks](https://github.com/GoogleCloudPlatform/buildpacks),
47+
you must define an entrypoint. By default you can use the `launcher` entrypoint:
48+
49+
50+
steps:
51+
...
52+
- name: "gcr.io/google-appengine/exec-wrapper"
53+
args: [...
54+
"-r", "launcher",
55+
"--", "bundle", "exec", "rake", "db:migrate"]
56+
57+
Alternatively, you can define your migration command as an entrypoint in `Procfile`,
58+
and use that instead of a direct command:
59+
60+
# Procfile
61+
web: bundle exec rails server
62+
migrate: bundle exec rake db:migrate
63+
64+
# cloudbuild.yaml
65+
steps:
66+
...
67+
- name: "gcr.io/google-appengine/exec-wrapper"
68+
args: [...
69+
"-r", "migrate"]
70+
3471
## Building and testing
3572

3673
See the main readme in this repository for information on the build, test, and

app-engine-exec-wrapper/execute.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ PRE_PULL=true
2626
CONTAINER_NETWORK=cloudbuild
2727

2828
OPTIND=1
29-
while getopts ":e:i:n:s:t:xP" opt; do
29+
while getopts ":e:i:n:s:t:xPr:" opt; do
3030
case $opt in
3131
e)
3232
ENV_PARAMS+=(-e "$OPTARG")
@@ -49,6 +49,9 @@ while getopts ":e:i:n:s:t:xP" opt; do
4949
P)
5050
PRE_PULL=
5151
;;
52+
r)
53+
ENTRYPOINT=$OPTARG
54+
;;
5255
\?)
5356
echo "Invalid option: -$OPTARG" >&2
5457
exit 1
@@ -97,10 +100,15 @@ if [ -n "${SQL_INSTANCES}" ]; then
97100
fi
98101
fi
99102

103+
if [ -n "${ENTRYPOINT}" ]; then
104+
ENTRYPOINT="--entrypoint \"${ENTRYPOINT}\""
105+
fi
106+
100107
echo
101108
echo "---------- EXECUTE COMMAND ----------"
102109
echo "$@"
103-
docker run --rm --volumes-from=${CONTAINER} --network=${CONTAINER_NETWORK} "${ENV_PARAMS[@]}" ${IMAGE} "$@"
110+
111+
docker run --rm ${ENTRYPOINT} --volumes-from=${CONTAINER} --network=${CONTAINER_NETWORK} "${ENV_PARAMS[@]}" ${IMAGE} "$@"
104112

105113
echo
106114
echo "---------- CLEANUP ----------"

0 commit comments

Comments
 (0)