New build system (#9)

This commit is contained in:
Ludovic Fernandez
2018-08-09 11:05:36 +02:00
committed by Michael
parent 585d48ff07
commit 72d3d9cd1c
6 changed files with 72 additions and 4 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
.idea
vendor/
/whoami

View File

@ -1,5 +1,12 @@
FROM golang:1.10 as builder
WORKDIR /go/src/github.com/containous/whoami
COPY . .
RUN go get -u github.com/golang/dep/cmd/dep
RUN make dependencies
RUN make build
# Create a minimal container to run a Golang static binary
FROM scratch
COPY whoami /
COPY --from=builder /go/src/github.com/containous/whoami/whoami .
ENTRYPOINT ["/whoami"]
EXPOSE 80

15
Gopkg.lock generated Normal file
View File

@ -0,0 +1,15 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/gorilla/websocket"
packages = ["."]
revision = "ea4d1f681babbce9545c9c5f3d5194a789c89f5b"
version = "v1.2.0"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "941e8dbe52e16e8a7dff4068b7ba53ae69a5748b29fbf2bcb5df3a063ac52261"
solver-name = "gps-cdcl"
solver-version = 1

35
Gopkg.toml Normal file
View File

@ -0,0 +1,35 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
name = "github.com/gorilla/websocket"
version = "1.2.0"
[prune]
non-go = true
go-tests = true
unused-packages = true

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
.PHONY: default build dependencies image
default: build
build:
CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o whoami
dependencies:
dep ensure -v
image:
docker build -t containous/whoami .

View File

@ -1,3 +0,0 @@
#!/bin/sh
CGO_ENABLED=0 go build -a --installsuffix cgo --ldflags="-s" -o whoami
docker build -t containous/whoami .