new build regime
* use new makefile style, remove two previous build systems * multi-stage build for the tiniest image
This commit is contained in:
parent
70d2dbea5c
commit
2ed757a038
23
Dockerfile
23
Dockerfile
|
@ -1,16 +1,11 @@
|
|||
FROM alpine:3.5
|
||||
|
||||
COPY docker/start.sh /bin/start.sh
|
||||
CMD ["/bin/start.sh"]
|
||||
|
||||
FROM golang:alpine as builder
|
||||
COPY main.go /go/src/github.com/discourse/discourse-auth-proxy/
|
||||
RUN apk add git
|
||||
RUN cd /go/src/github.com/discourse/discourse-auth-proxy \
|
||||
&& go get \
|
||||
&& go build
|
||||
|
||||
RUN apk add --no-cache -t build-deps build-base git go mercurial \
|
||||
&& export GOPATH=/go \
|
||||
&& cd /go/src/github.com/discourse/discourse-auth-proxy \
|
||||
&& go get \
|
||||
&& go build -o /bin/discourse-auth-proxy \
|
||||
&& apk del --purge build-deps \
|
||||
# Don't ask me why, but purging the go package leaves behind about
|
||||
# 8MB of cruft in /usr/lib/go which we have to nuke by hand
|
||||
&& rm -rf /go /usr/lib/go
|
||||
FROM alpine:latest
|
||||
COPY --from=builder /go/bin/discourse-auth-proxy /bin/
|
||||
COPY start.sh /bin/start.sh
|
||||
CMD ["/bin/start.sh"]
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
IMAGE := discourse/auth-proxy
|
||||
TAG := $(shell date -u +%Y%m%d.%H%M%S)
|
||||
|
||||
.PHONY: default
|
||||
default: push
|
||||
@printf "${IMAGE}:${TAG} ready\n"
|
||||
|
||||
.PHONY: push
|
||||
push: build
|
||||
docker push ${IMAGE}:${TAG}
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
docker build -t ${IMAGE}:${TAG} .
|
|
@ -43,7 +43,7 @@ Docker Image
|
|||
You may run using docker using
|
||||
|
||||
```
|
||||
docker run samsaffron/discourse-auth-proxy
|
||||
docker run discourse/discourse-auth-proxy
|
||||
```
|
||||
|
||||
Running will display configuration instructions
|
||||
|
|
6
build
6
build
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
docker build --build-arg=http_proxy=$http_proxy -t discourse/auth-proxy .
|
||||
docker push discourse/auth-proxy
|
|
@ -1,6 +0,0 @@
|
|||
FROM gliderlabs/alpine
|
||||
|
||||
ADD build_image/discourse-auth-proxy /bin/discourse-auth-proxy
|
||||
ADD start.sh /bin/start.sh
|
||||
|
||||
CMD ["/bin/start.sh"]
|
|
@ -1,40 +0,0 @@
|
|||
require 'pty'
|
||||
|
||||
version = "1.0.0"
|
||||
$nocache = false
|
||||
|
||||
def run(command)
|
||||
lines = []
|
||||
PTY.spawn(command) do |stdin, stdout, pid|
|
||||
begin
|
||||
stdin.each do |line|
|
||||
lines << line
|
||||
puts line
|
||||
end
|
||||
rescue Errno::EIO
|
||||
# we are done
|
||||
end
|
||||
end
|
||||
|
||||
lines
|
||||
end
|
||||
|
||||
|
||||
def build(path)
|
||||
lines = run("cd #{path} && docker build #{$nocache ? "--no-cache" : ""} .")
|
||||
lines[-1]["successfully built ".length..-1].strip
|
||||
end
|
||||
|
||||
img = build("build_image")
|
||||
pwd = `pwd`.strip
|
||||
run "docker run --rm -it -v #{pwd}/build_image:/shared #{img}"
|
||||
|
||||
repo = "samsaffron/discourse-auth-proxy"
|
||||
tag = "#{repo}:#{version}"
|
||||
latest = "#{repo}:#{latest}"
|
||||
|
||||
img = build(".")
|
||||
run "docker tag -f #{img} #{tag}"
|
||||
run "docker tag -f #{img} #{latest}"
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
FROM gliderlabs/alpine
|
||||
|
||||
RUN apk --update add bash git go mercurial
|
||||
RUN mkdir -p /gopath/src/github.com/discourse && cd /gopath/src/github.com/discourse && git clone https://github.com/discourse/discourse-auth-proxy
|
||||
ENV GOPATH /gopath
|
||||
RUN mkdir -p /gopath
|
||||
RUN cd /gopath/src/github.com/discourse/discourse-auth-proxy && go get
|
||||
RUN cd /gopath/src/github.com/discourse/discourse-auth-proxy && CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-w' .
|
||||
|
||||
CMD cp /gopath/src/github.com/discourse/discourse-auth-proxy/discourse-auth-proxy /shared
|
||||
|
|
@ -29,7 +29,7 @@ if [ -z "$GOOD" ]; then
|
|||
echo "SSO_URL=http://someurl"
|
||||
echo "HOST_PORT=3001"
|
||||
echo
|
||||
echo "docker run -d --restart=always -e ORIGIN_URL=\$ORIGIN_URL -e PROXY_URL=http://0.0.0.0:80 -e SSO_SECRET=\$SSO_SECRET -e SSO_URL=\$SSO_URL -p \$HOST_PORT:80 samsaffron/discourse-auth-proxy"
|
||||
echo "docker run -d --restart=always -e ORIGIN_URL=\$ORIGIN_URL -e PROXY_URL=http://0.0.0.0:80 -e SSO_SECRET=\$SSO_SECRET -e SSO_URL=\$SSO_URL -p \$HOST_PORT:80 discourse/discourse-auth-proxy"
|
||||
else
|
||||
exec /bin/discourse-auth-proxy
|
||||
fi
|
Loading…
Reference in New Issue