Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature : multi-stage Dockerfile #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]