瀏覽代碼

add entrypoint for service

Yeuoly 6 月之前
父節點
當前提交
6ba6c9ace7
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 8 2
      Dockerfile
  2. 1 0
      entrypoint.sh

+ 8 - 2
Dockerfile

@@ -14,9 +14,14 @@ WORKDIR /app
 # build
 RUN go build -ldflags "-X 'internal.manifest.VersionX=${VERSION}' -X 'internal.manifest.BuildTimeX=$(date -u +%Y-%m-%dT%H:%M:%S%z)'" -o /app/main cmd/server/main.go
 
+# copy entrypoint.sh
+COPY entrypoint.sh /app/entrypoint.sh
+RUN chmod +x /app/entrypoint.sh
+
 FROM ubuntu:24.04
 
 COPY --from=builder /app/main /app/main
+COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh
 
 WORKDIR /app
 
@@ -34,5 +39,6 @@ RUN if [ "$PLATFORM" = "local" ]; then \
 ENV PLATFORM=$PLATFORM
 ENV GIN_MODE=release
 
-# run the server, using bash as the entrypoint to recycle resources
-CMD ["/bin/bash", "-c", "exec /app/main"]
+# run the server, using sh as the entrypoint to avoid process being the root process
+# and using bash to recycle resources
+CMD ["/bin/bash", "-c", "/app/entrypoint.sh"]

+ 1 - 0
entrypoint.sh

@@ -0,0 +1 @@
+bash -c "exec /app/main"