From 3d3089bc2ff5816e59b41a363bbb7e94b22ba259 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 26 Sep 2025 09:10:33 +0200 Subject: [PATCH] Add dockerfile and deploy script --- Dockerfile | 45 +++++++++++++++++++++++++++++++++++++++++++++ deploy.sh | 3 +++ 2 files changed, 48 insertions(+) create mode 100644 Dockerfile create mode 100644 deploy.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d21229d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# Build stage +# FROM golang:1.23-bullseye as base +FROM golang:bullseye as base + +RUN adduser \ + --disabled-password \ + --gecos "" \ + --home "/nonexistent" \ + --shell "/sbin/nologin" \ + --no-create-home \ + --uid 65532 \ + small-user + +WORKDIR /app + +COPY . . + +# RUN go mod download +# RUN go mod verify + +RUN GOFLAGS=-mod=vendor CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main . + +# Final stage +# Pick your poison +# Ordered by size desc +# FROM ubuntu:latest +# FROM alpine:latest +FROM scratch + +# For ubuntu +# RUN apt-get update && apt-get install -y curl vim git && apt-get clean + +# Copy the binary from the build stage +COPY --from=base /app/main /main + +# Copy necessary files from the build stage +COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=base /etc/passwd /etc/passwd +COPY --from=base /etc/group /etc/group + +# Use the non-root user +# USER small-user +EXPOSE 8090 + +CMD ["/main", "--http=0.0.0.0:8090", "serve"] \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..de3171e --- /dev/null +++ b/deploy.sh @@ -0,0 +1,3 @@ +go mod vendor +docker build . -t docker.site.quack-lab.dev/pb-shoppinglist:latest +docker push docker.site.quack-lab.dev/pb-shoppinglist:latest \ No newline at end of file