From fc843bc0dd64653b64d3b03fd31e8143dafda359 Mon Sep 17 00:00:00 2001 From: Kapil Verma Date: Wed, 23 Nov 2022 14:36:21 +0530 Subject: [PATCH] dockerfile changes --- go/samples/http/Dockerfile | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/go/samples/http/Dockerfile b/go/samples/http/Dockerfile index 2759f15b..af993c85 100644 --- a/go/samples/http/Dockerfile +++ b/go/samples/http/Dockerfile @@ -1,25 +1,16 @@ -# Build Stage # First pull Golang image -FROM golang:1.19-alpine as build-env +FROM golang:1.19-alpine ENV APP_NAME sqlcommenter-http -ENV CMD_PATH main.go - -# Copy application data into image -COPY . $GOPATH/src/$APP_NAME + +# Set workdir WORKDIR $GOPATH/src/$APP_NAME + +# Copy application data into image +COPY . . # Budild application -RUN CGO_ENABLED=0 go build -v -o /$APP_NAME $GOPATH/src/$APP_NAME/$CMD_PATH - -# Run Stage -FROM alpine:3.16.3 - -# Set environment variable -ENV APP_NAME sqlcommenter-http - -# Copy only required data into this image -COPY --from=build-env /$APP_NAME . +RUN CGO_ENABLED=0 go build -v # Expose application port EXPOSE 8081