From c257293ae2605886a1f6263b9eca827831e930a5 Mon Sep 17 00:00:00 2001 From: wrench Date: Sat, 2 Dec 2023 02:31:22 +0530 Subject: [PATCH] fix(docker): runtime error --- Dockerfile | 9 +++++---- docker-compose.yaml | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f3374d5..889d8a92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,9 @@ FROM golang:1.21 AS builder RUN apt-get update && apt-get upgrade -y && apt-get install build-essential -y WORKDIR /app COPY . . -RUN CGO_ENABLED=0 GOOS=`go env GOHOSTOS` GOARCH=`go env GOHOSTARCH` go build ./cmd/fsb/ -o out/fsb -ldflags="-w -s" . +RUN CGO_ENABLED=0 go build -o /app/fsb -ldflags="-w -s" ./cmd/fsb -FROM golang:1.21 -COPY --from=builder /app/out/fsb /app/fsb -CMD ["/app/fsb"] \ No newline at end of file +FROM scratch +COPY --from=builder /app/fsb /app/fsb +EXPOSE ${PORT} +ENTRYPOINT ["/app/fsb"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 3df551be..7317377f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,10 +5,11 @@ services: build: context: . dockerfile: Dockerfile - restart: always container_name: fsb + restart: always volumes: - - ./:/app/:rw - env_file: fsb.env + - ./logs:/app/logs + env_file: + - fsb.env ports: - - 8080:8080 \ No newline at end of file + - "${PORT:-8038}:${PORT:-8038}" \ No newline at end of file