Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Go Httpbin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Nix
Go Httpbin
Commits
c429c2d3
Unverified
Commit
c429c2d3
authored
4 years ago
by
Will McCutchen
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #42 from mccutchen/cloud-run
Deploy to Google Cloud Run
parents
524a9e33
58525662
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Dockerfile
+3
-3
3 additions, 3 deletions
Dockerfile
Makefile
+44
-12
44 additions, 12 deletions
Makefile
bin/gcloud
+5
-3
5 additions, 3 deletions
bin/gcloud
with
52 additions
and
18 deletions
Dockerfile
+
3
−
3
View file @
c429c2d3
FROM
golang:1.1
3
FROM
golang:1.1
5
WORKDIR
/go/src/github.com/mccutchen/go-httpbin
COPY
Makefile .
RUN
make deps
# Manually implement the subset of `make deps` we need to build the image
RUN
cd
/tmp
&&
go get
-u
github.com/kevinburke/go-bindata/...
COPY
. .
RUN
make build buildtests
...
...
This diff is collapsed.
Click to expand it.
Makefile
+
44
−
12
View file @
c429c2d3
...
...
@@ -4,13 +4,22 @@
# go-httpbin:latest image use `make imagepush VERSION=latest)`
VERSION
?=
$(
shell git rev-parse
--short
HEAD
)
# Override these values to deploy to a different
App Engine
project
# Override these values to deploy to a different
Cloud Run
project
GCLOUD_PROJECT
?=
httpbingo
GCLOUD_ACCOUNT
?=
mccutchen@gmail.com
GCLOUD_REGION
?=
us-central1
# The version tag for the Cloud Run deployment (override this to adjust
# pre-production URLs)
GCLOUD_TAG
?=
"v-
$(
VERSION
)
"
# Run gcloud in a container to avoid needing to install the SDK locally
GCLOUD_COMMAND
?=
./bin/gcloud
# We push docker images to both docker hub and gcr.io
DOCKER_TAG_DOCKERHUB
?=
mccutchen/go-httpbin:
$(
VERSION
)
DOCKER_TAG_GCLOUD
?=
gcr.io/
$(
GCLOUD_PROJECT
)
/go-httpbin:
$(
VERSION
)
# Built binaries will be placed here
DIST_PATH
?=
dist
...
...
@@ -81,19 +90,41 @@ lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
# =============================================================================
#
deploy &
run locally
# run locally
# =============================================================================
deploy
:
build gcloud-auth
$(
GCLOUD_COMMAND
)
--account
=
$(
GCLOUD_ACCOUNT
)
app deploy
--quiet
--project
=
$(
GCLOUD_PROJECT
)
--version
=
$(
VERSION
)
--promote
run
:
build
$(
DIST_PATH
)
/go-httpbin
stagedeploy
:
build gcloud-auth
$(
GCLOUD_COMMAND
)
--account
=
$(
GCLOUD_ACCOUNT
)
app deploy
--quiet
--project
=
$(
GCLOUD_PROJECT
)
--version
=
$(
VERSION
)
--no-promote
# =============================================================================
# deploy to google cloud run
# =============================================================================
deploy
:
gcloud-auth imagepush
$(
GCLOUD_COMMAND
)
beta run deploy
\
$(
GCLOUD_PROJECT
)
\
--image
=
$(
DOCKER_TAG_GCLOUD
)
\
--revision-suffix
=
$(
VERSION
)
\
--tag
=
$(
GCLOUD_TAG
)
\
--project
=
$(
GCLOUD_PROJECT
)
\
--region
=
$(
GCLOUD_REGION
)
\
--allow-unauthenticated
\
--platform
=
managed
stagedeploy
:
gcloud-auth imagepush
$(
GCLOUD_COMMAND
)
beta run deploy
\
$(
GCLOUD_PROJECT
)
\
--image
=
$(
DOCKER_TAG_GCLOUD
)
\
--revision-suffix
=
$(
VERSION
)
\
--tag
=
$(
GCLOUD_TAG
)
\
--project
=
$(
GCLOUD_PROJECT
)
\
--region
=
$(
GCLOUD_REGION
)
\
--allow-unauthenticated
\
--platform
=
managed
\
--no-traffic
gcloud-auth
:
@$(
GCLOUD_COMMAND
)
auth list |
grep
'^\*'
|
grep
-q
$(
GCLOUD_ACCOUNT
)
||
$(
GCLOUD_COMMAND
)
auth login
$(
GCLOUD_ACCOUNT
)
run
:
build
$(
DIST_PATH
)
/go-httpbin
@$(
GCLOUD_COMMAND
)
auth print-access-token | docker login
-u
oauth2accesstoken
--password-stdin
https://gcr.io
watch
:
$(TOOL_REFLEX)
reflex
-s
-r
'\.(go|html)$$'
make run
...
...
@@ -103,10 +134,11 @@ watch: $(TOOL_REFLEX)
# docker images
# =============================================================================
image
:
docker build
-t
mccutchen/go-httpbin:
$(
VERSION
)
.
docker build
-t
$(
DOCKER_TAG_DOCKERHUB
)
-t
$(
DOCKER_TAG_GCLOUD
)
.
imagepush
:
image
docker push mccutchen/go-httpbin:
$(
VERSION
)
docker push
$(
DOCKER_TAG_GCLOUD
)
docker push
$(
DOCKER_TAG_GCLOUD
)
# =============================================================================
...
...
This diff is collapsed.
Click to expand it.
bin/gcloud
+
5
−
3
View file @
c429c2d3
...
...
@@ -6,10 +6,12 @@
# Adapted from this helpful blog post:
# https://blog.scottlowe.org/2018/09/13/running-gcloud-cli-in-a-docker-container/
GCLOUD_SDK_TAG
=
"312.0.0"
exec
docker run
\
--rm
\
-ti
\
--rm
-it
\
--workdir
/code
\
-v
$PWD
:/code
\
-v
$HOME
/.config/gcloud:/root/.config/gcloud
\
google/cloud-sdk gcloud
$*
google/cloud-sdk:
$GCLOUD_SDK_TAG
\
gcloud
$*
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment