Skip to content

Commit

Permalink
fix(Dockerfile): fix Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kubeway committed Jun 15, 2019
1 parent f68592b commit c7b117c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 105 deletions.
13 changes: 7 additions & 6 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Build the manager binary
FROM golang:1.12 as builder
FROM registry.cn-hangzhou.aliyuncs.com/knative-sample/golang:1.12 as builder

# Copy in the go src
WORKDIR /go/src/github.com/knative-samples/knload/
WORKDIR /go/src/github.com/knative-sample/knload/
COPY cmd/ cmd/
COPY pkg/ pkg/
COPY vendor/ vendor/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/httpload code.aliyun.com/knative-samples/http-client/cmd/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/knload github.com/knative-sample/knload/cmd/

FROM registry.cn-hangzhou.aliyuncs.com/knative-sample/alpine-sh:3.9

FROM alpine:3.9
WORKDIR /app/
RUN mkdir -p /app/bin/
COPY --from=builder /go/src/code.aliyun.com/knative-samples/http-client/bin/httpload /app/bin/httpload
ENTRYPOINT ["/app/bin/httpload"]
COPY --from=builder /go/src/github.com/knative-sample/knload/bin/knload /app/bin/knload
ENTRYPOINT ["/app/bin/knload"]


2 changes: 1 addition & 1 deletion build/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

NAME="httpload"
NAME="knload"
GIT_COMMIT="$(git rev-parse --verify HEAD)"
GIT_BRANCH=`git branch | grep \* | cut -d ' ' -f2`
TAG="$(date +%Y''%m''%d''%H''%M''%S)"
Expand Down
12 changes: 6 additions & 6 deletions cmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"os"

"github.com/knative-sample/knload/pkg/httpload"
"github.com/knative-sample/knload/pkg/knload"
"github.com/golang/glog"
)

Expand Down Expand Up @@ -53,9 +53,9 @@ func run(stopCh <-chan struct{}, ops *options.Options) {
}

ss := strings.Split(ops.Stages, ",")
var stages []*httpload.Stage
var stages []*knload.Stage
for _, stageStr := range ss {
stage := &httpload.Stage{}
stage := &knload.Stage{}
_ss := strings.Split(stageStr, ":")
if len(_ss) != 2 {
continue
Expand All @@ -81,16 +81,16 @@ func run(stopCh <-chan struct{}, ops *options.Options) {
stages = append(stages, stage)
}

hl := &httpload.HttpLoad{
kl := &knload.Knload{
Namespace: ops.Namespace,
LabelSelector: ops.LabelSelector,
GatewayAddress: ops.GatewayAddress,
SavePath: ops.SavePath,
ServiceUrl: ops.ServiceUrl,
Stages: stages,
ResultChan: make(chan *httpload.Result, 1000),
ResultChan: make(chan *knload.Result, 1000),
}
hl.Run()
kl.Run()
os.Exit(0)

<-stopCh
Expand Down
80 changes: 0 additions & 80 deletions pkg/httpload/testrun.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/httpload/draw.go → pkg/knload/draw.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package httpload
package knload

import (
"encoding/base64"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/golang/glog"
)

func (hl *HttpLoad) Draw() {
func (hl *Knload) Draw() {
var wg sync.WaitGroup
var concurrentList []int
var responseTimeList []float64
Expand Down
20 changes: 10 additions & 10 deletions pkg/httpload/httpload.go → pkg/knload/httpload.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package httpload
package knload

import (
"context"
Expand Down Expand Up @@ -32,7 +32,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
)

type HttpLoad struct {
type Knload struct {
Debug bool
Namespace string
LabelSelector string
Expand Down Expand Up @@ -85,7 +85,7 @@ func init() {
// * In-cluster config if running in cluster
//
// * $HOME/.kube/config if exists
func (hl *HttpLoad) getKubeconfig() (*rest.Config, error) {
func (hl *Knload) getKubeconfig() (*rest.Config, error) {
// If a flag is specified with the config location, use that
if len(kubeconfig) > 0 {
return clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
Expand All @@ -109,7 +109,7 @@ func (hl *HttpLoad) getKubeconfig() (*rest.Config, error) {
return nil, fmt.Errorf("could not locate a kubeconfig")
}

func (hl *HttpLoad) Run() {
func (hl *Knload) Run() {
var wg sync.WaitGroup
var wg1 sync.WaitGroup
var wg2 sync.WaitGroup
Expand Down Expand Up @@ -226,7 +226,7 @@ type DrawHtml struct {
C3CSS interface{}
}

func (hl *HttpLoad) run(s *Stage, resultChan chan *Result) {
func (hl *Knload) run(s *Stage, resultChan chan *Result) {
var wg1 sync.WaitGroup
wg1.Add(s.Duration + 1)
rm := map[int]*Result{}
Expand Down Expand Up @@ -311,7 +311,7 @@ func (hl *HttpLoad) run(s *Stage, resultChan chan *Result) {
close(resultChan)
}

func (hl *HttpLoad) doRequest(resultChan chan float64) {
func (hl *Knload) doRequest(resultChan chan float64) {
// do request
responseTime, err := hl.getResponseTime()
if err != nil {
Expand All @@ -322,7 +322,7 @@ func (hl *HttpLoad) doRequest(resultChan chan float64) {
resultChan <- responseTime
}

func (hl *HttpLoad) getResponseTime() (responseTime float64, err error) {
func (hl *Knload) getResponseTime() (responseTime float64, err error) {
u, err := url.Parse(fmt.Sprintf("http://%s", hl.ServiceUrl))
if err != nil {
glog.Error(err)
Expand Down Expand Up @@ -410,11 +410,11 @@ func (hl *HttpLoad) getResponseTime() (responseTime float64, err error) {
return float64(t4.Sub(t1)) / float64(time.Second), nil
}

func (hl *HttpLoad) logResponseTime(msg string, t2, t1 time.Time) {
func (hl *Knload) logResponseTime(msg string, t2, t1 time.Time) {
glog.V(5).Infof("%s %s\n", msg, t2.Sub(t1))
}

func (hl *HttpLoad) dialContext(network string) func(ctx context.Context, network, addr string) (net.Conn, error) {
func (hl *Knload) dialContext(network string) func(ctx context.Context, network, addr string) (net.Conn, error) {
return func(ctx context.Context, _, addr string) (net.Conn, error) {
return (&net.Dialer{
Timeout: 10 * time.Second,
Expand All @@ -424,7 +424,7 @@ func (hl *HttpLoad) dialContext(network string) func(ctx context.Context, networ
}
}

func (hl *HttpLoad) readResponseBody(resp *http.Response) string {
func (hl *Knload) readResponseBody(resp *http.Response) string {
bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
glog.Fatal(err)
Expand Down

0 comments on commit c7b117c

Please sign in to comment.