Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various build improvements #40

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subspace-linux-amd64
bindata.go
31 changes: 7 additions & 24 deletions Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@ FROM golang:1.11.5
MAINTAINER github.com/subspacecloud/subspace

RUN apt-get update \
&& apt-get install -y git \
&& apt-get install -y git make \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /go/src/github.com/subspacecloud/subspace

RUN go get -v \
github.com/jteeuwen/go-bindata/... \
github.com/dustin/go-humanize \
github.com/julienschmidt/httprouter \
github.com/Sirupsen/logrus \
github.com/gorilla/securecookie \
golang.org/x/crypto/acme/autocert \
golang.org/x/time/rate \
golang.org/x/crypto/bcrypt \
go.uber.org/zap \
gopkg.in/gomail.v2 \
github.com/crewjam/saml \
github.com/dgrijalva/jwt-go \
github.com/skip2/go-qrcode
WORKDIR /src

COPY Makefile ./
# go.mod and go.sum if exists
COPY go.* ./
COPY *.go ./
COPY static ./static
COPY templates ./templates
Expand All @@ -30,11 +18,6 @@ COPY email ./email
ARG BUILD_VERSION=unknown

ENV GODEBUG="netdns=go http2server=0"
ENV GOPATH="/go"

RUN go-bindata --pkg main static/... templates/... email/... \
&& go fmt \
&& go vet --all

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -v --compiler gc --ldflags "-extldflags -static -s -w -X main.version=${BUILD_VERSION}" -o /usr/bin/subspace-linux-amd64
RUN make BUILD_VERSION=${BUILD_VERSION}
RUN mv subspace-linux-amd64 /usr/bin/subspace-linux-amd64
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all: subspace-linux-amd64

BUILD_VERSION?=unknown

subspace-linux-amd64:
go generate \
&& go fmt \
&& go vet --all
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -v --compiler gc --ldflags "-extldflags -static -s -w -X main.version=${BUILD_VERSION}" -o subspace-linux-amd64

clean:
rm -f subspace-linux-amd64 bindata.go

.PHONY: clean
7 changes: 7 additions & 0 deletions assets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import (
_ "github.com/jteeuwen/go-bindata"
)

//go:generate go run github.com/jteeuwen/go-bindata/go-bindata --pkg main static/... templates/... email/...
20 changes: 20 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module github.com/subspacecloud/subspace

require (
github.com/beevik/etree v1.1.0 // indirect
github.com/crewjam/saml v0.0.0-20190521120225-344d075952c9
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dustin/go-humanize v1.0.0
github.com/gorilla/securecookie v1.1.1
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/jteeuwen/go-bindata v3.0.8-0.20180305030458-6025e8de665b+incompatible
github.com/julienschmidt/httprouter v1.3.0
github.com/kr/pretty v0.1.0 // indirect
github.com/russellhaering/goxmldsig v0.0.0-20180430223755-7acd5e4a6ef7 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9
golang.org/x/crypto v0.0.0-20191010185427-af544f31c8ac
golang.org/x/net v0.0.0-20191009170851-d66e71096ffb
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
)
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

"github.com/julienschmidt/httprouter"

log "github.com/Sirupsen/logrus"
"github.com/crewjam/saml"
"github.com/crewjam/saml/samlsp"
"github.com/gorilla/securecookie"
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/acme/autocert"
)

Expand Down