Skip to content
Snippets Groups Projects
Commit 3e5a9a00 authored by Will McCutchen's avatar Will McCutchen
Browse files

Deploy to App Engine

parent ee604d64
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ go: ...@@ -4,6 +4,7 @@ go:
- '1.9' - '1.9'
- '1.10' - '1.10'
- '1.11' - '1.11'
- '1.12'
go_import_path: github.com/mccutchen/go-httpbin go_import_path: github.com/mccutchen/go-httpbin
script: script:
- make lint - make lint
......
*
!server
!main
!*.js
.PHONY: clean deps image imagepush run test testcover .PHONY: clean deploy deps image imagepush lint run stagedeploy test testcover
GCLOUD_PROJECT ?= httpbingo
TEST_ARGS ?= -race
VERSION ?= $(shell git rev-parse --short HEAD)
COMMIT := $(shell git rev-parse --short HEAD)
GENERATED_ASSETS_PATH := httpbin/assets/assets.go GENERATED_ASSETS_PATH := httpbin/assets/assets.go
BIN_DIR := $(GOPATH)/bin
GOLINT := $(BIN_DIR)/golint BIN_DIR := $(GOPATH)/bin
GOLINT := $(BIN_DIR)/golint
GOBINDATA := $(BIN_DIR)/go-bindata GOBINDATA := $(BIN_DIR)/go-bindata
TEST_ARGS := -race
# =============================================================================
# build
# =============================================================================
build: dist/go-httpbin build: dist/go-httpbin
dist/go-httpbin: $(GENERATED_ASSETS_PATH) cmd/go-httpbin/*.go httpbin/*.go go.mod dist/go-httpbin: assets cmd/go_httpbin/*.go httpbin/*.go go.mod
mkdir -p dist mkdir -p dist
go build -o dist/go-httpbin ./cmd/go-httpbin go build -o dist/go-httpbin ./cmd/go_httpbin
assets: $(GENERATED_ASSETS_PATH)
clean:
rm -r dist
$(GENERATED_ASSETS_PATH): $(GOBINDATA) static/* $(GENERATED_ASSETS_PATH): $(GOBINDATA) static/*
$(GOBINDATA) -o $(GENERATED_ASSETS_PATH) -pkg=assets -prefix=static static $(GOBINDATA) -o $(GENERATED_ASSETS_PATH) -pkg=assets -prefix=static static
...@@ -22,6 +33,10 @@ $(GENERATED_ASSETS_PATH): $(GOBINDATA) static/* ...@@ -22,6 +33,10 @@ $(GENERATED_ASSETS_PATH): $(GOBINDATA) static/*
sed -i.bak 's/Xml/XML/g' $(GENERATED_ASSETS_PATH) sed -i.bak 's/Xml/XML/g' $(GENERATED_ASSETS_PATH)
rm $(GENERATED_ASSETS_PATH).bak rm $(GENERATED_ASSETS_PATH).bak
# =============================================================================
# test & lint
# =============================================================================
test: test:
go test $(TEST_ARGS) ./... go test $(TEST_ARGS) ./...
...@@ -35,24 +50,44 @@ lint: $(GOLINT) ...@@ -35,24 +50,44 @@ lint: $(GOLINT)
$(GOLINT) -set_exit_status ./... $(GOLINT) -set_exit_status ./...
go vet ./... go vet ./...
# =============================================================================
# deploy & run locally
# =============================================================================
deploy: build
gcloud app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --promote
stagedeploy: build
gcloud app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --no-promote
run: build run: build
./dist/go-httpbin ./dist/go-httpbin
clean:
rm -r dist
image: $(GENERATED_ASSETS_PATH) cmd/go-httpbin/*.go httpbin/*.go # =============================================================================
docker build -t mccutchen/go-httpbin:$(COMMIT) . # docker images
# =============================================================================
image: assets cmd/go-httpbin/*.go httpbin/*.go
docker build -t mccutchen/go-httpbin:$(VERSION) .
imagepush: image imagepush: image
docker push mccutchen/go-httpbin:$(COMMIT) docker push mccutchen/go-httpbin:$(VERSION)
assets: $(GENERATED_ASSETS_PATH)
# =============================================================================
# dependencies
# =============================================================================
deps: $(GOLINT) $(GOBINDATA) deps: $(GOLINT) $(GOBINDATA)
$(GOLINT): # Can't install from working dir because of go mod issues:
go get -u golang.org/x/lint/golint #
# go get -u github.com/kevinburke/go-bindata/...
# go: finding github.com/kevinburke/go-bindata/... latest
# go get github.com/kevinburke/go-bindata/...: no matching versions for query "latest"
#
# So we get out of the go modules path to install.
$(GOBINDATA): $(GOBINDATA):
cd /tmp && go get -u github.com/kevinburke/go-bindata/... cd /tmp && go get -u github.com/kevinburke/go-bindata/...
$(GOLINT):
go get -u golang.org/x/lint/golint
app.yaml 0 → 100644
---
runtime: go112
main: ./cmd/go_httpbin
# redirect everything to https
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
File moved
This diff is collapsed.
{
"name": "go-httpbin",
"type": "docker",
"public": true,
"alias": [
"httpbingo.org"
]
}
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<title>go-httpbin(1): HTTP Client Testing Service</title> <title>go-httpbin(1): HTTP Client Testing Service</title>
<style type='text/css' media='all'> <style type='text/css' media='all'>
/* style: man */ /* style: man */
body#manpage {margin:0} body#manpage {margin:0;background:#fff;}
.mp {max-width:100ex;padding:0 9ex 1ex 4ex} .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0} .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
.mp h2 {margin:10px 0 0 0} .mp h2 {margin:10px 0 0 0}
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143} .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
.mp h2 {font-size:16px;line-height:1.25} .mp h2 {font-size:16px;line-height:1.25}
.mp h1 {font-size:20px;line-height:2} .mp h1 {font-size:20px;line-height:2}
.mp {text-align:justify;background:#fff}
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211} .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201} .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
.mp u {text-decoration:underline} .mp u {text-decoration:underline}
......
{
"name": "go-httpbin",
"profile": "up",
"hooks": {
"build": "GOOS=linux GOARCH=amd64 make && mv dist/go-httpbin server",
"clean": "rm -f server"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment