-
Notifications
You must be signed in to change notification settings - Fork 465
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
Enable go modules #124
Enable go modules #124
Changes from 6 commits
d62168f
06c8698
bc7c80a
2522547
4ebca9e
e4d005f
870b332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,8 @@ cover.out | |
bin/ | ||
.idea/ | ||
vendor | ||
cert.pem | ||
key.pem | ||
private.pem | ||
redis-per-second.conf | ||
redis.conf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
FROM golang:1.10.4 AS build | ||
WORKDIR /go/src/github.com/lyft/ratelimit | ||
FROM golang:1.14 AS build | ||
WORKDIR /ratelimit | ||
|
||
ENV GOPROXY=https://proxy.golang.org | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, not terribly familiar with go modules. Why is this needed in docker but not in the makefile for local builds? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a mirror that can be used to speed up module downloads. We use it in Contour. |
||
COPY go.mod go.sum /ratelimit/ | ||
RUN go mod download | ||
|
||
COPY src src | ||
COPY script script | ||
COPY vendor vendor | ||
COPY glide.yaml glide.yaml | ||
COPY glide.lock glide.lock | ||
COPY proto proto | ||
|
||
RUN script/install-glide | ||
RUN glide install | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux go build -o /usr/local/bin/ratelimit -ldflags="-w -s" -v github.com/lyft/ratelimit/src/service_cmd | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/ratelimit -ldflags="-w -s" -v github.com/envoyproxy/ratelimit/src/service_cmd | ||
|
||
FROM alpine:3.8 AS final | ||
FROM alpine:3.11 AS final | ||
RUN apk --no-cache add ca-certificates | ||
COPY --from=build /usr/local/bin/ratelimit /bin/ratelimit | ||
COPY --from=build /go/bin/ratelimit /bin/ratelimit |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
ifeq ("$(GOPATH)","") | ||
$(error GOPATH must be set) | ||
endif | ||
export GO111MODULE=on | ||
MODULE = github.com/envoyproxy/ratelimit | ||
|
||
SHELL := /bin/bash | ||
GOREPO := ${GOPATH}/src/github.com/lyft/ratelimit | ||
GOREPO := ${GOPATH}/src/github.com/envoyproxy/ratelimit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this is not used anymore in the rest of the file. Not sure if this is needed for the internal Lyft build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't used anywhere else in the makefile we can delete it. |
||
|
||
.PHONY: bootstrap | ||
bootstrap: | ||
script/install-glide | ||
glide install | ||
go get github.com/golang/mock/[email protected] | ||
|
||
.PHONY: bootstrap_tests | ||
bootstrap_tests: | ||
cd ./vendor/github.com/golang/mock/mockgen && go install | ||
define REDIS_STUNNEL | ||
cert = private.pem | ||
pid = /var/run/stunnel.pid | ||
|
@@ -33,6 +28,7 @@ redis.conf: | |
echo "$$REDIS_STUNNEL" >> $@ | ||
redis-per-second.conf: | ||
echo "$$REDIS_PER_SECOND_STUNNEL" >> $@ | ||
|
||
.PHONY: bootstrap_redis_tls | ||
bootstrap_redis_tls: redis.conf redis-per-second.conf | ||
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \ | ||
|
@@ -51,27 +47,27 @@ docs_format: | |
.PHONY: fix_format | ||
fix_format: | ||
script/docs_fix_format | ||
go fmt $(shell glide nv) | ||
go fmt $(MODULE)/... | ||
|
||
.PHONY: check_format | ||
check_format: docs_format | ||
@gofmt -l $(shell glide nv | sed 's/\.\.\.//g') | tee /dev/stderr | read && echo "Files failed gofmt" && exit 1 || true | ||
@gofmt -l $(shell go list -f '{{.Dir}}' ./...) | tee /dev/stderr | read && echo "Files failed gofmt" && exit 1 || true | ||
|
||
.PHONY: compile | ||
compile: | ||
mkdir -p ${GOREPO}/bin | ||
cd ${GOREPO}/src/service_cmd && go build -o ratelimit ./ && mv ./ratelimit ${GOREPO}/bin | ||
cd ${GOREPO}/src/client_cmd && go build -o ratelimit_client ./ && mv ./ratelimit_client ${GOREPO}/bin | ||
cd ${GOREPO}/src/config_check_cmd && go build -o ratelimit_config_check ./ && mv ./ratelimit_config_check ${GOREPO}/bin | ||
mkdir -p ./bin | ||
go build -mod=readonly -o ./bin/ratelimit $(MODULE)/src/service_cmd | ||
go build -mod=readonly -o ./bin/ratelimit_client $(MODULE)/src/client_cmd | ||
go build -mod=readonly -o ./bin/ratelimit_config_check $(MODULE)/src/config_check_cmd | ||
|
||
.PHONY: tests_unit | ||
tests_unit: compile | ||
go test -race ./... | ||
go test -race $(MODULE)/... | ||
|
||
.PHONY: tests | ||
tests: compile | ||
go test -race -tags=integration ./... | ||
go test -race -tags=integration $(MODULE)/... | ||
|
||
.PHONY: docker | ||
docker: tests | ||
docker build . -t lyft/ratelimit:`git rev-parse HEAD` | ||
docker build . -t envoyproxy/ratelimit:`git rev-parse HEAD` |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is bootstrap gone here, but still present in the Makefile? Should mockgen install remain part of bootstrap tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching, at one point I removed bootstrap entirely, then put it back. I'm going to keep it there so I will restore to the travis file.