From 0e5fc970eb67240fd313aa3f0d746284978cba1d Mon Sep 17 00:00:00 2001 From: proffapt Date: Fri, 5 Jul 2024 00:20:19 +0530 Subject: [PATCH] feat: improvised docker build --- backend/Dockerfile | 18 +++++++++--------- backend/metaploy/postinstall.sh | 8 +++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 4dfbf6e..8ff2c9e 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -8,20 +8,20 @@ RUN go mod download COPY . . -RUN CGO_ENABLED=1 GOOS=linux go build -o /app --tags "fts5" -a -ldflags '-linkmode external -extldflags "-static"' . +RUN CGO_ENABLED=1 GOOS=linux go build -o ./build -a -ldflags '-linkmode external -extldflags "-static"' -FROM busybox:1.36-musl +FROM alpine:latest AS app -RUN mkdir -p /etc/ssl/certs +RUN apk --no-cache add ca-certificates tzdata bash -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +ENV TZ="Asia/Kolkata" -COPY metaploy/naarad-api.metaploy.conf / +WORKDIR /app -COPY metaploy/postinstall.sh / +COPY metaploy/ ./ -RUN chmod +x /postinstall.sh +RUN chmod +x ./postinstall.sh -COPY --from=builder /app /app +COPY --from=builder /src/build . -CMD ["/postinstall.sh", "/app"] \ No newline at end of file +CMD ["./postinstall.sh", "./build"] \ No newline at end of file diff --git a/backend/metaploy/postinstall.sh b/backend/metaploy/postinstall.sh index 698aba6..56eb8fe 100644 --- a/backend/metaploy/postinstall.sh +++ b/backend/metaploy/postinstall.sh @@ -1,16 +1,14 @@ #!/bin/sh cleanup() { - echo "Container stopped. Removing nginx configuration." - rm /etc/nginx/sites-enabled/naarad-api.metaploy.conf + echo "Container stopped. Removing nginx configuration." + rm /etc/nginx/sites-enabled/naarad-api.metaploy.conf } trap 'cleanup' SIGQUIT SIGTERM SIGHUP "${@}" & -cp /naarad-api.metaploy.conf /etc/nginx/sites-enabled +cp ./naarad-api.metaploy.conf /etc/nginx/sites-enabled wait $! - -echo "lmao" \ No newline at end of file