From 45ee560c67bed2bf7365a2e6722463e374ceed66 Mon Sep 17 00:00:00 2001 From: elops-od Date: Fri, 15 Dec 2023 11:15:35 +0200 Subject: [PATCH] fix --- Dockerfile | 10 +++++++++- main.go | 14 +++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0b0c08f..6fc20b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -o ./echo-server ./ma ######## Start a new stage from scratch ####### FROM alpine:3.19.0 + ENV HTTP_PORT=8080 ENV HTTPS_PORT=8443 ENV GRPC_PORT=50051 @@ -16,8 +17,15 @@ ENV GRPCS_PORT=50053 EXPOSE 8080 8443 50051 50053 +RUN apk add --no-cache ca-certificates bash curl jq yq busybox-extras \ + && rm -rf /var/lib/apk/lists/* + USER 1001 +SHELL ["/bin/bash"] + WORKDIR /app -COPY ./certs /app/certs + +COPY --from=builder /app/certs /app/certs COPY --from=builder /app/echo-server /app/echo-server + ENTRYPOINT ["/app/echo-server"] diff --git a/main.go b/main.go index 4d76518..3d3fb33 100644 --- a/main.go +++ b/main.go @@ -22,9 +22,9 @@ import ( func main() { httpPort := env.GetDefault("HTTP_PORT", "8080") - httpsPort := env.GetDefault("HTTP_PORT", "8443") - grpcPort := env.GetDefault("HTTP_PORT", "50051") - grpcsPort := env.GetDefault("HTTP_PORT", "50053") + httpsPort := env.GetDefault("HTTPS_PORT", "8443") + grpcPort := env.GetDefault("GRPC_PORT", "50051") + grpcsPort := env.GetDefault("GRPCS_PORT", "50053") var wg sync.WaitGroup wg.Add(1) @@ -161,11 +161,3 @@ func (s *server) GrpcPing(ctx context.Context, req *pb.Request) (*pb.Response, e } return response, nil } - -func getEnv(key, defaultValue string) string { - value := os.Getenv(key) - if len(value) == 0 { - return defaultValue - } - return value -}