Skip to content

Commit 45e409c

Browse files
authored
Merge pull request #13 from intelops/test-docker
updated dockerfile
2 parents 9b65b8e + 4e4d7b5 commit 45e409c

File tree

12 files changed

+70
-53
lines changed

12 files changed

+70
-53
lines changed

.github/workflows/tracetest-container-pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ jobs:
2525
- uses: docker/setup-buildx-action@v1
2626
name: Set up Docker Buildx
2727

28+
-
29+
name: Set up Go environment
30+
uses: actions/setup-go@v4
31+
with:
32+
go-version: '1.21.1'
33+
34+
-
35+
name: Build server
36+
run: make dist/tracetest-server
37+
env:
38+
GO111MODULE: on
39+
2840
-
2941
name: Login to ghcr registry
3042
uses: docker/login-action@v2

.github/workflows/tracetest-container.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ jobs:
3030
id: buildx
3131
uses: docker/setup-buildx-action@v2
3232

33+
- name: Set up Go environment
34+
uses: actions/setup-go@v4
35+
with:
36+
go-version: '1.21.1'
37+
38+
- name: Build server
39+
run: make dist/tracetest-server
40+
env:
41+
GO111MODULE: on
42+
3343
- name: Docker metadata
3444
id: metadata
3545
uses: docker/metadata-action@v4
@@ -42,7 +52,7 @@ jobs:
4252
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
4353
flavor: |
4454
latest=true
45-
55+
4656
- name: Login to GitHub Container Registry
4757
uses: docker/login-action@v2
4858
with:

Dockerfile

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,8 @@
1-
# Stage 1: Build
2-
FROM golang:1.21 AS builder
3-
4-
# Set necessary environment variables
5-
ENV CGO_ENABLED=1
6-
ENV GOOS=linux
7-
ENV GOARCH=amd64
8-
9-
# Install build-essential for cgo
10-
RUN apt-get update && apt-get install -y build-essential
11-
12-
# Create a working directory
13-
WORKDIR /app
14-
15-
# Copy source code
16-
COPY ./cli ./cli
17-
COPY ./server ./server
18-
19-
# Build the tracetest server and CLI
20-
RUN cd server && go build -o /app/tracetest-server
21-
RUN cd cli && go build -o /app/tracetest
22-
23-
# Stage 2: Final Image
241
FROM alpine
252

263
WORKDIR /app
274

28-
# Copy the built binaries from the builder stage
29-
COPY --from=builder /app/tracetest-server /app/tracetest-server
30-
COPY --from=builder /app/tracetest /app/tracetest
5+
COPY ./tracetest-server /app/tracetest-server
316

327
# Adding /app folder on $PATH to allow users to call tracetest cli on docker
338
ENV PATH="$PATH:/app"

builds/tracetest-server

70.6 MB
Binary file not shown.

Makefile renamed to makefile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
VERSION?="dev"
22
TAG?=$(VERSION)
3-
GORELEASER_VERSION=1.19.2-pro
3+
#GORELEASER_VERSION=1.21.2-pro
44

55
PROJECT_ROOT=${PWD}
66

7-
CURRENT_GORELEASER_VERSION := $(shell goreleaser --version | head -n 9 | tail -n 1 | tr -s ' ' | cut -d' ' -f2-)
8-
goreleaser-version:
9-
ifneq "$(CURRENT_GORELEASER_VERSION)" "$(GORELEASER_VERSION)"
10-
@printf "\033[0;31m Bad goreleaser version $(CURRENT_GORELEASER_VERSION), please install $(GORELEASER_VERSION)\033[0m\n\n"
11-
@printf "\033[0;31m Tracetest requires goreleaser pro installed (licence not necessary for local builds)\033[0m\n\n"
12-
@printf "\033[0;33m See https://goreleaser.com/install/ \033[0m\n\n"
13-
@exit 1
14-
endif
7+
#CURRENT_GORELEASER_VERSION := $(shell goreleaser --version | head -n 9 | tail -n 1 | tr -s ' ' | cut -d' ' -f2-)
8+
#goreleaser-version:
9+
#ifneq "$(CURRENT_GORELEASER_VERSION)" "$(GORELEASER_VERSION)"
10+
# @printf "\033[0;31m Bad goreleaser version $(CURRENT_GORELEASER_VERSION), please install $(GORELEASER_VERSION)\033[0m\n\n"
11+
# @printf "\033[0;31m Tracetest requires goreleaser pro installed (licence not necessary for local builds)\033[0m\n\n"
12+
# @printf "\033[0;33m See https://goreleaser.com/install/ \033[0m\n\n"
13+
# @exit 1
14+
#endif
1515

1616

1717
CLI_SRC_FILES := $(shell find cli -type f)
18-
dist/tracetest: goreleaser-version generate-cli $(CLI_SRC_FILES)
19-
goreleaser build --single-target --clean --snapshot --id cli
20-
find ./dist -name 'tracetest' -exec cp {} ./dist \;
18+
dist/tracetest: generate-cli $(CLI_SRC_FILES)
19+
env GOOS=linux CGO_ENABLED=0 GO111MODULE=on /usr/local/go/bin/go build -o builds/tracetest-server server/main.go
20+
# goreleaser build --single-target --clean --snapshot --id cli
21+
# find ./dist -name 'tracetest' -exec cp {} ./dist \;
2122

2223
SERVER_SRC_FILES := $(shell find server -type f)
23-
dist/tracetest-server: goreleaser-version generate-server $(SERVER_SRC_FILES)
24-
goreleaser build --single-target --clean --snapshot --id server
25-
find ./dist -name 'tracetest-server' -exec cp {} ./dist \;
24+
dist/tracetest-server: generate-server $(SERVER_SRC_FILES)
25+
@echo "Choose a command run:"
26+
env GOOS=linux CGO_ENABLED=0 GO111MODULE=on go build -o tracetest-server server/main.go
27+
28+
#goreleaser build --single-target --clean --snapshot --id server
29+
# find ./dist -name 'tracetest-server' -exec cp {} ./dist \;
2630

2731
web/node_modules: web/package.json web/package-lock.json
2832
cd web; npm install
@@ -109,3 +113,10 @@ clean: ## cleans the build artifacts
109113
rm -rf web/build
110114
rm -rf web/node_modules
111115
docker image rm "kubeshop/tracetest:$(TAG)"
116+
117+
vendor: go.mod go.sum
118+
@echo Downloading modules
119+
@go mod tidy
120+
@go mod download
121+
@go mod vendor
122+
@go mod tidy

server/app/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (app *App) Start(opts ...appOption) error {
281281

282282
// use the tenant middleware on complete router
283283
router.Use(middleware.TenantMiddleware)
284-
284+
//
285285
apiRouter := router.
286286
PathPrefix(app.cfg.ServerPathPrefix()).
287287
PathPrefix("/api").
@@ -303,7 +303,7 @@ func (app *App) Start(opts ...appOption) error {
303303
if isNewInstall {
304304
provision(provisioner, app.provisioningFile)
305305
}
306-
306+
//http server started
307307
httpServer := &http.Server{
308308
Addr: fmt.Sprintf(":%d", app.cfg.ServerPort()),
309309
Handler: handlers.CompressHandler(router),

server/config/server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"fmt"
5+
"log"
56
"os"
67
"strings"
78
)
@@ -99,7 +100,8 @@ func (c *AppConfig) PostgresConnString() string {
99100
func (c *AppConfig) ServerPathPrefix() string {
100101
c.mu.Lock()
101102
defer c.mu.Unlock()
102-
103+
pathprefix := c.vp.GetString("server.pathPrefix")
104+
log.Println(" Server Path Prefix", pathprefix)
103105
return c.vp.GetString("server.pathPrefix")
104106
}
105107

server/executor/pipeline.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package executor
33
import (
44
"context"
55
"fmt"
6+
"log"
67
"reflect"
78
)
89

@@ -83,12 +84,14 @@ func (p *Pipeline) Begin(ctx context.Context, job Job) {
8384

8485
func (p *Pipeline) Start() {
8586
for _, step := range p.steps {
87+
log.Println("Step for Pipeline Start",step)
8688
step.Driver.Start()
8789
}
8890
}
8991

9092
func (p *Pipeline) Stop() {
9193
for _, step := range p.steps {
94+
log.Println("Step for Pipeline Stop",step)
9295
step.Driver.Stop()
9396
}
9497
}

server/go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module github.com/kubeshop/tracetest/server
22

33
go 1.20
44

5+
56
replace k8s.io/client-go => k8s.io/client-go v0.18.0
67

78
require (
@@ -29,7 +30,7 @@ require (
2930
github.com/goware/urlx v0.3.2
3031
github.com/hashicorp/go-multierror v1.1.1
3132
github.com/j2gg0s/otsql v0.14.0
32-
github.com/jackc/pgx/v5 v5.4.2
33+
github.com/jackc/pgx/v5 v5.4.3
3334
github.com/jhump/protoreflect v1.12.0
3435
github.com/json-iterator/go v1.1.12
3536
github.com/mitchellh/mapstructure v1.5.0
@@ -97,7 +98,7 @@ require (
9798
github.com/inconshreveable/mousetrap v1.0.1 // indirect
9899
github.com/jackc/pgpassfile v1.0.0 // indirect
99100
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
100-
github.com/jackc/puddle/v2 v2.2.0 // indirect
101+
github.com/jackc/puddle/v2 v2.2.1 // indirect
101102
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
102103
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
103104
github.com/jcmturner/gofork v1.7.6 // indirect

server/go.sum

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,15 +1077,15 @@ github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXg
10771077
github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o=
10781078
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
10791079
github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA=
1080-
github.com/jackc/pgx/v5 v5.4.2 h1:u1gmGDwbdRUZiwisBm/Ky2M14uQyUP65bG8+20nnyrg=
1081-
github.com/jackc/pgx/v5 v5.4.2/go.mod h1:q6iHT8uDNXWiFNOlRqJzBTaSH3+2xCXkokxHZC5qWFY=
1080+
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
1081+
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
10821082
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
10831083
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
10841084
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
10851085
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
10861086
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
1087-
github.com/jackc/puddle/v2 v2.2.0 h1:RdcDk92EJBuBS55nQMMYFXTxwstHug4jkhT5pq8VxPk=
1088-
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
1087+
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
1088+
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
10891089
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
10901090
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
10911091
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
@@ -1098,8 +1098,6 @@ github.com/jcmturner/gokrb5/v8 v8.4.3 h1:iTonLeSJOn7MVUtyMT+arAn5AKAPrkilzhGw8wE
10981098
github.com/jcmturner/gokrb5/v8 v8.4.3/go.mod h1:dqRwJGXznQrzw6cWmyo6kH+E7jksEQG/CyVWsJEsJO0=
10991099
github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY=
11001100
github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc=
1101-
github.com/jackc/puddle/v2 v2.2.0 h1:RdcDk92EJBuBS55nQMMYFXTxwstHug4jkhT5pq8VxPk=
1102-
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
11031101
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
11041102
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
11051103
github.com/jhump/gopoet v0.0.0-20190322174617-17282ff210b3/go.mod h1:me9yfT6IJSlOL3FCfrg+L6yzUEZ+5jW6WHt4Sk+UPUI=

server/http/middleware/tenant.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ func TenantMiddleware(next http.Handler) http.Handler {
2222
tenantID := getTenantIDFromRequest(r)
2323

2424
// if tenant id exists and is invalid we return a 400 error
25+
if r.URL.Path == "/" {
26+
w.WriteHeader(http.StatusOK)
27+
w.Write([]byte("OK"))
28+
return
29+
}
2530
if tenantID != "" && !isValidUUID(tenantID) {
2631
err := fmt.Errorf("invalid tenant id: %s", tenantID)
2732
w.WriteHeader(http.StatusBadRequest)
File renamed without changes.

0 commit comments

Comments
 (0)