Skip to content

Commit

Permalink
Utilize golang-builder for builds.
Browse files Browse the repository at this point in the history
Make the build/push/tag process a bit more configurable.
Support cross-compilation and output binary compression, which defaults to false.
Minimize output image by using busybox as a base.
Default cmd is now /config/auth_config.yml .
  • Loading branch information
akatrevorjay committed Nov 12, 2015
1 parent 3fc8c28 commit b836c65
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Supported authorization methods:
A public Docker image is available on Docker Hub: [cesanta/docker_auth:stable](https://registry.hub.docker.com/u/cesanta/docker_auth/).

The binary takes a single argument - path to the config file.
If no arguments are given, the Dockerfile defaults to `/config/auth_config.yml`.

Example command line:

Expand Down
1 change: 1 addition & 0 deletions auth_server/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
auth_server
Godeps/
5 changes: 3 additions & 2 deletions auth_server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.5
FROM busybox
EXPOSE 5001
ADD auth_server /
ENTRYPOINT ["/auth_server"]
CMD ["/config/auth_config.yml"]
COPY auth_server .
34 changes: 24 additions & 10 deletions auth_server/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
.PHONY: update-deps build docker-build
MAKEFLAGS += --warn-undefined-variables
IMAGE ?= cesanta/docker_auth
COMPRESS_BINARY ?= false

BUILDER_IMAGE ?= centurylink/golang-builder
BUILDER_IMAGE_EXTRA-build-cross = -cross
BUILDER_OPTS-docker-build = -v /var/run/docker.sock:/var/run/docker.sock

.PHONY: %

all: build
local: build-local

update-deps:
go get -v -u -f github.com/jteeuwen/go-bindata/... .
go get -v -u -f github.com/tools/godep github.com/jteeuwen/go-bindata/... .

build:
godep:
godep save

build-local: update-deps
go generate ./...
go build

docker-build: update-deps build
docker build -t cesanta/docker_auth -f Dockerfile .
build build-cross docker-build: update-deps godep
docker run --rm -v $(PWD):/src -e COMPRESS_BINARY=$(COMPRESS_BINARY) $(BUILDER_OPTS-$@) $(BUILDER_IMAGE)$(BUILDER_IMAGE_EXTRA-$@) $(IMAGE)

docker-tag-%:
docker tag -f $(IMAGE):latest $(IMAGE):$*

docker-push-latest:
docker push cesanta/docker_auth:latest
docker-push-%: docker-tag-%
docker push $(IMAGE):$*

docker-push-stable:
docker tag -f cesanta/docker_auth:latest cesanta/docker_auth:stable
docker push cesanta/docker_auth:stable
# Shortcut for latest
docker-push: docker-push-latest
2 changes: 1 addition & 1 deletion auth_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

package main
package main // import "github.com/cesanta/docker_auth/auth_server"

import (
"crypto/tls"
Expand Down

0 comments on commit b836c65

Please sign in to comment.