Reduce image size of modelmgmtservice 17/13217/2
authorgyuyoung <gyoue200125@gmail.com>
Mon, 29 Jul 2024 13:36:38 +0000 (22:36 +0900)
committergyuyoung <gyoue200125@gmail.com>
Wed, 31 Jul 2024 13:31:49 +0000 (22:31 +0900)
- Updated stage1 to build modelmgmtservice golang binary
- Added stage2 to run modelmgmtservice golang binary with compact
  environment
- Change alpine tag from 'latest' to '3.20' for fixing development environment

Issue-ID: AIMLFW-116

Change-Id: Idce95bef25c4505f0edb0a810bfebdc96b89283a
Signed-off-by: gyuyoung <gyoue200125@gmail.com>
Dockerfile

index 4d4d951..9a0d75f 100644 (file)
@@ -16,7 +16,7 @@
 #
 # ==================================================================================
 #Base Image
-FROM golang:1.21
+FROM golang:1.21-alpine AS builder
 
 # location in the container
 ENV MME_DIR /home/app/
@@ -32,8 +32,17 @@ RUN LOG_FILE_NAME=testing.log go test ./...
 #Build all packages from current dir into bin 
 RUN go build -o mme_bin .
 
+FROM alpine:3.20
+
+RUN apk update && apk add bash
+RUN apk add --no-cache bash
+
+WORKDIR /app
+
+COPY --from=builder /home/app/mme_bin .
+
 #Start the app
-ENTRYPOINT [ "sh", "-c", "${MME_DIR}/mme_bin"]
+ENTRYPOINT ["/app/mme_bin"]
 
 #Expose the ports for external communication
 EXPOSE 8082