From 7582c0a9742782432a9434bb99e0ad421c26c725 Mon Sep 17 00:00:00 2001 From: elskow Date: Tue, 22 Oct 2024 03:04:41 +0700 Subject: [PATCH] feat(videochat): use distroless approach --- videochat-cp/.dockerignore | 6 ++++++ videochat-cp/Dockerfile | 14 +++----------- videochat-cp/scripts/entrypoint.sh | 11 ----------- 3 files changed, 9 insertions(+), 22 deletions(-) create mode 100644 videochat-cp/.dockerignore delete mode 100644 videochat-cp/scripts/entrypoint.sh diff --git a/videochat-cp/.dockerignore b/videochat-cp/.dockerignore new file mode 100644 index 0000000..8079549 --- /dev/null +++ b/videochat-cp/.dockerignore @@ -0,0 +1,6 @@ +.git +node_modules +dist +Dockerfile +docker-compose.yaml +*.md \ No newline at end of file diff --git a/videochat-cp/Dockerfile b/videochat-cp/Dockerfile index b8cd98e..bb11890 100644 --- a/videochat-cp/Dockerfile +++ b/videochat-cp/Dockerfile @@ -8,23 +8,15 @@ COPY go.mod go.sum ./ RUN go mod download COPY . . - RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o main . -FROM alpine:3.18 - -RUN adduser -D appuser +FROM gcr.io/distroless/static WORKDIR /app COPY --from=builder /app/main . COPY config.yaml . -COPY scripts/entrypoint.sh . - -RUN chown -R appuser:appuser /app && \ - chmod +x entrypoint.sh -USER appuser +USER nonroot:nonroot -ENTRYPOINT ["./entrypoint.sh"] -CMD ["./main", "--config", "config.yaml"] +CMD ["./main", "--config", "config.yaml"] \ No newline at end of file diff --git a/videochat-cp/scripts/entrypoint.sh b/videochat-cp/scripts/entrypoint.sh deleted file mode 100644 index c16d33e..0000000 --- a/videochat-cp/scripts/entrypoint.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# Read the port from the config file -PORT=$(grep 'address' config.yaml | sed 's/.*://') - -# Expose the port dynamically -echo "Exposing port $PORT" -echo "EXPOSE $PORT" > Dockerfile.dynamic - -# Run the main application -exec "$@"