Skip to content

Commit

Permalink
Use go mod (cadence-workflow#2314)
Browse files Browse the repository at this point in the history
* Modify Docker files and Makefile accordingly
  • Loading branch information
wxing1292 authored Aug 14, 2019
1 parent 3ef6d2f commit dcef9dc
Show file tree
Hide file tree
Showing 9 changed files with 522 additions and 43 deletions.
27 changes: 16 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
ARG TARGET=server

# Can be used in case a proxy is necessary
ARG GOPROXY

# Build Cadence binaries
FROM golang:1.12.7-alpine AS builder

RUN apk add --update --no-cache ca-certificates make git curl mercurial bzr

WORKDIR /go/src/github.com/uber/cadence
WORKDIR /cadence

# Making sure that dependency is not touched
ENV GOFLAGS="-mod=readonly"

RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | INSTALL_DIRECTORY=/usr/local/bin sh
COPY Gopkg.* ./
RUN dep ensure -v -vendor-only
# Copy go mod dependencies and build cache
COPY go.* .
RUN go mod download

COPY . .
RUN sed -i 's/dep-ensured//g' Makefile
RUN CGO_ENABLED=0 make copyright cadence-cassandra-tool cadence-sql-tool cadence cadence-server


Expand Down Expand Up @@ -46,11 +51,11 @@ ENV CADENCE_HOME /etc/cadence
RUN mkdir -p /etc/cadence

COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin
COPY --from=builder /go/src/github.com/uber/cadence/cadence-cassandra-tool /usr/local/bin
COPY --from=builder /go/src/github.com/uber/cadence/cadence-sql-tool /usr/local/bin
COPY --from=builder /go/src/github.com/uber/cadence/cadence /usr/local/bin
COPY --from=builder /go/src/github.com/uber/cadence/cadence-server /usr/local/bin
COPY --from=builder /go/src/github.com/uber/cadence/schema /etc/cadence/schema
COPY --from=builder /cadence/cadence-cassandra-tool /usr/local/bin
COPY --from=builder /cadence/cadence-sql-tool /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin
COPY --from=builder /cadence/cadence-server /usr/local/bin
COPY --from=builder /cadence/schema /etc/cadence/schema

COPY docker/entrypoint.sh /docker-entrypoint.sh
COPY config/dynamicconfig /etc/cadence/config/dynamicconfig
Expand Down Expand Up @@ -79,7 +84,7 @@ CMD /start.sh
# Cadence CLI
FROM alpine AS cadence-cli

COPY --from=builder /go/src/github.com/uber/cadence/cadence /usr/local/bin
COPY --from=builder /cadence/cadence /usr/local/bin

ENTRYPOINT ["cadence"]

Expand Down
23 changes: 10 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,8 @@ PKG_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT)%,$(TEST_DIRS))
# Packages are specified as import paths.
GOCOVERPKG_ARG := -coverpkg="$(PROJECT_ROOT)/common/...,$(PROJECT_ROOT)/service/...,$(PROJECT_ROOT)/client/...,$(PROJECT_ROOT)/tools/..."

dep-ensured:
./install-dep.sh
dep ensure

yarpc-install:
go mod vendor
go get './vendor/go.uber.org/thriftrw'
go get './vendor/go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc'

Expand All @@ -97,38 +94,38 @@ thriftc: yarpc-install $(THRIFTRW_GEN_SRC)
copyright: cmd/tools/copyright/licensegen.go
GOOS= GOARCH= go run ./cmd/tools/copyright/licensegen.go --verifyOnly

cadence-cassandra-tool: dep-ensured $(TOOLS_SRC)
cadence-cassandra-tool: $(TOOLS_SRC)
go build -i -o cadence-cassandra-tool cmd/tools/cassandra/main.go

cadence-sql-tool: dep-ensured $(TOOLS_SRC)
cadence-sql-tool: $(TOOLS_SRC)
go build -i -o cadence-sql-tool cmd/tools/sql/main.go

cadence: dep-ensured $(TOOLS_SRC)
cadence: $(TOOLS_SRC)
go build -i -o cadence cmd/tools/cli/main.go

cadence-server: dep-ensured $(ALL_SRC)
cadence-server: $(ALL_SRC)
go build -ldflags '$(GO_BUILD_LDFLAGS)' -i -o cadence-server cmd/server/cadence.go cmd/server/server.go

bins_nothrift: lint copyright cadence-cassandra-tool cadence-sql-tool cadence cadence-server

bins: thriftc bins_nothrift

test: dep-ensured bins
test: bins
@rm -f test
@rm -f test.log
@for dir in $(TEST_DIRS); do \
go test -timeout 20m -race -coverprofile=$@ "$$dir" $(TEST_TAG) | tee -a test.log; \
done;

test_eventsV2: dep-ensured bins
test_eventsV2: bins
@rm -f test_eventsV2
@rm -f test_eventsV2.log
@echo Running integration test
@for dir in $(INTEG_TEST_ROOT); do \
go test -timeout 20m -coverprofile=$@ "$$dir" -v $(TEST_TAG) -eventsV2=true | tee -a test_eventsV2.log; \
done;

test_eventsV2_xdc: dep-ensured bins
test_eventsV2_xdc: bins
@rm -f test_eventsV2_xdc
@rm -f test_eventsV2_xdc.log
@echo Running integration test for cross dc:
Expand All @@ -137,7 +134,7 @@ test_eventsV2_xdc: dep-ensured bins
done;

# need to run xdc tests with race detector off because of ringpop bug causing data race issue
test_xdc: dep-ensured bins
test_xdc: bins
@rm -f test
@rm -f test.log
@for dir in $(INTEG_TEST_XDC_ROOT); do \
Expand Down Expand Up @@ -185,7 +182,7 @@ cover_integration_ci: cover_integration_profile
cover_xdc_ci: cover_xdc_profile
goveralls -coverprofile=$(BUILD)/cover.out -service=travis-ci || echo -e "\x1b[31mCoveralls failed\x1b[m"; \

lint: dep-ensured
lint:
@echo Running linter
@lintFail=0; for file in $(ALL_SRC); do \
golint "$$file"; \
Expand Down
29 changes: 29 additions & 0 deletions cmd/server/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2019 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

// +build tools

package tools

// the 2 dependency below are used for yarpc / thriftrw compatible code generation
import (
_ "go.uber.org/thriftrw"
_ "go.uber.org/yarpc/encoding/thrift/thriftrw-plugin-yarpc"
)
5 changes: 2 additions & 3 deletions docker/buildkite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ RUN go get github.com/axw/gocov/gocov
RUN go get github.com/mattn/goveralls
RUN go get golang.org/x/tools/cmd/cover

# The golang Docker sets the $GOPATH to be /go
# https://github.com/docker-library/golang/blob/c1baf037d71331eb0b8d4c70cff4c29cf124c5e0/1.4/Dockerfile
RUN mkdir -p /go/src/github.com/uber/cadence
WORKDIR /go/src/github.com/uber/cadence
RUN mkdir -p /cadence
WORKDIR /cadence
12 changes: 6 additions & 6 deletions docker/buildkite/docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ services:
- cassandra
- mysql
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down Expand Up @@ -112,7 +112,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down Expand Up @@ -144,7 +144,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down Expand Up @@ -175,7 +175,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down Expand Up @@ -206,7 +206,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down Expand Up @@ -238,7 +238,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
networks:
services-network:
aliases:
Expand Down
10 changes: 5 additions & 5 deletions docker/buildkite/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ services:
- cassandra
- mysql
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
networks:
services-network:
Expand Down Expand Up @@ -109,7 +109,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
networks:
services-network:
Expand Down Expand Up @@ -140,7 +140,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
networks:
services-network:
Expand Down Expand Up @@ -170,7 +170,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
networks:
services-network:
Expand Down Expand Up @@ -201,7 +201,7 @@ services:
- elasticsearch
- kafka
volumes:
- ../../:/go/src/github.com/uber/cadence
- ../../:/cadence
- /usr/bin/buildkite-agent:/usr/bin/buildkite-agent
networks:
services-network:
Expand Down
106 changes: 106 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
module github.com/uber/cadence

go 1.12

require (
github.com/DataDog/zstd v1.4.0 // indirect
github.com/Shopify/sarama v1.23.0
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 // indirect
github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7
github.com/benbjohnson/clock v0.0.0-20161215174838-7dc76406b6d3 // indirect
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b // indirect
github.com/bsm/sarama-cluster v2.1.15+incompatible
github.com/cactus/go-statsd-client v3.1.1+incompatible
github.com/cch123/elasticsql v0.0.0-20190321073543-a1a440758eb9
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b // indirect
github.com/davecgh/go-spew v1.1.1
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/emirpasic/gods v0.0.0-20190624094223-e689965507ab
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fatih/color v0.0.0-20181010231311-3f9d52f7176a
github.com/fatih/structtag v1.0.0 // indirect
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/gocql/gocql v0.0.0-20171220143535-56a164ee9f31
github.com/gogo/googleapis v1.2.0 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang/mock v1.3.1
github.com/google/uuid v1.1.1
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/go-version v1.2.0
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jmoiron/sqlx v1.2.0
github.com/jonboulle/clockwork v0.1.0
github.com/kisielk/errcheck v1.2.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/lib/pq v1.2.0 // indirect
github.com/m3db/prometheus_client_golang v0.8.1
github.com/m3db/prometheus_client_model v0.1.0 // indirect
github.com/m3db/prometheus_common v0.1.0 // indirect
github.com/m3db/prometheus_procfs v0.8.1 // indirect
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/olekukonko/tablewriter v0.0.1
github.com/olivere/elastic v6.2.21+incompatible
github.com/opentracing/opentracing-go v1.1.0
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709
github.com/pierrec/lz4 v0.0.0-20190701081048-057d66e894a4 // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/prashantv/protectmem v0.0.0-20171002184600-e20412882b3a // indirect
github.com/prometheus/common v0.6.0 // indirect
github.com/prometheus/procfs v0.0.3 // indirect
github.com/robfig/cron v1.2.0
github.com/samuel/go-thrift v0.0.0-20190219015601-e8b6b52668fe // indirect
github.com/sirupsen/logrus v1.2.0
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect
github.com/stretchr/testify v1.3.0
github.com/uber-common/bark v1.2.1 // indirect
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber-go/kafka-client v0.2.2
github.com/uber-go/mapdecode v1.0.0 // indirect
github.com/uber-go/tally v3.3.11+incompatible
github.com/uber/jaeger-client-go v2.16.0+incompatible // indirect
github.com/uber/jaeger-lib v2.0.0+incompatible // indirect
github.com/uber/ringpop-go v0.8.5
github.com/uber/tchannel-go v1.14.0
github.com/urfave/cli v1.20.0
github.com/valyala/fastjson v1.4.1
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.uber.org/atomic v1.4.0
go.uber.org/cadence v0.0.0-20190702231331-27b0ba2bc456
go.uber.org/dig v1.7.0 // indirect
go.uber.org/fx v1.9.0 // indirect
go.uber.org/goleak v0.10.0 // indirect
go.uber.org/multierr v1.1.0
go.uber.org/net/metrics v1.1.0 // indirect
go.uber.org/thriftrw v1.20.0
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
go.uber.org/yarpc v1.39.0
go.uber.org/zap v1.10.0
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 // indirect
golang.org/x/net v0.0.0-20190628185345-da137c7871d7
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
golang.org/x/tools v0.0.0-20190703183924-abb7e64e8926 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/grpc v1.22.1 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
gopkg.in/jcmturner/gokrb5.v7 v7.3.0 // indirect
gopkg.in/validator.v2 v2.0.0-20180514200540-135c24b11c19
gopkg.in/yaml.v2 v2.2.2
)

replace github.com/jmoiron/sqlx v1.2.0 => github.com/mfateev/sqlx v0.0.0-20180910213730-fa49b1cf03f7
Loading

0 comments on commit dcef9dc

Please sign in to comment.