Skip to content

Commit

Permalink
updated dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
akash4sh committed Oct 16, 2023
1 parent 96308b5 commit 83ba755
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 35 deletions.
35 changes: 15 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
# Stage 1: Build
FROM golang:1.21 AS builder
FROM golang:1.20 as builder

# Install build-essential for cgo
RUN apt-get update && apt-get install -y build-essential
WORKDIR /tracetest
# Copy the Go Modules manifests
COPY ./ ./
#RUN go mod download

# Create a working directory
WORKDIR /app

# Copy source code
COPY ./cli ./cli
COPY ./server ./server
# Build
RUN make dist/tracetest-server
# RUN cd server
# RUN env GOOS=linux CGO_ENABLED=0 GO111MODULE=on /usr/local/go/bin/go build -o tracetest-server

# Build the tracetest server and CLI
RUN cd server && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o /app/tracetest-server
RUN cd cli && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o /app/tracetest

# Stage 2: Final Image
FROM alpine

WORKDIR /app

# Copy the built binaries from the builder stage
COPY --from=builder /app/server/tracetest-server /app/tracetest-server
COPY --from=builder /app/tracetest /app/tracetest
COPY --from=builder /tracetest/tracetest-server /app/tracetest-server

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

EXPOSE 11633/tcp
# EXPOSE 11633/tcp

ENTRYPOINT ["/app/tracetest-server", "serve"]
ENTRYPOINT ["/app/tracetest-server", "serve"]
Binary file renamed server/tracetest-server → builds/tracetest-server
Binary file not shown.
41 changes: 26 additions & 15 deletions Makefile → makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
VERSION?="dev"
TAG?=$(VERSION)
GORELEASER_VERSION=1.19.2-pro
#GORELEASER_VERSION=1.21.2-pro

PROJECT_ROOT=${PWD}

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


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

SERVER_SRC_FILES := $(shell find server -type f)
dist/tracetest-server: goreleaser-version generate-server $(SERVER_SRC_FILES)
goreleaser build --single-target --clean --snapshot --id server
find ./dist -name 'tracetest-server' -exec cp {} ./dist \;
dist/tracetest-server: generate-server $(SERVER_SRC_FILES)
@echo "Choose a command run:"
env GOOS=linux CGO_ENABLED=0 GO111MODULE=on /usr/local/go/bin/go build -o tracetest-server server/main.go

#goreleaser build --single-target --clean --snapshot --id server
# find ./dist -name 'tracetest-server' -exec cp {} ./dist \;

web/node_modules: web/package.json web/package-lock.json
cd web; npm install
Expand Down Expand Up @@ -109,3 +113,10 @@ clean: ## cleans the build artifacts
rm -rf web/build
rm -rf web/node_modules
docker image rm "kubeshop/tracetest:$(TAG)"

vendor: go.mod go.sum
@echo Downloading modules
@go mod tidy
@go mod download
@go mod vendor
@go mod tidy
1 change: 1 addition & 0 deletions server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module github.com/kubeshop/tracetest/server

go 1.20


replace k8s.io/client-go => k8s.io/client-go v0.18.0

require (
Expand Down
File renamed without changes.

0 comments on commit 83ba755

Please sign in to comment.