diff --git a/Dockerfile b/Dockerfile index 0dcc346..71270c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,22 @@ -FROM golang:1.17 +FROM golang:1.17 AS build RUN useradd -m netlify -ADD . /src -RUN cd /src && make deps build_linux && mv gocommerce /usr/local/bin/ +WORKDIR /src +COPY . . + +# Build the application +RUN make deps build_linux +RUN mv gocommerce /usr/local/bin/ + +# Stage 2: Create a minimal image +FROM scratch + +# Copy the built binary from the first stage +COPY --from=build /usr/local/bin/gocommerce /usr/local/bin/gocommerce USER netlify -CMD ["gocommerce"] EXPOSE 8080 + +CMD ["gocommerce"] +