-
Notifications
You must be signed in to change notification settings - Fork 513
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
git executable not found in golang:alpine image #209
Comments
Duplicate of #157 (see also #119). In short,
|
@tianon sorry, but without git, |
@sethyates you can use multi stage docker builds to have a build container and a runtime container to get around this. This ends up in a smaller image.
This way your image is around 10mb+your binary |
Maybe this can help you. FROM golang:1.12 as builder
# Set Environment Variables
ENV HOME /app
ENV CGO_ENABLED 0
ENV GOOS linux
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build app
RUN go build -a -installsuffix cgo -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the pre-built binary file from the previous stage
COPY --from=builder /app/main .
EXPOSE 8080
CMD [ "./main" ] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The point is that the Go compiler itself requires the If the argument goes that you should just use alpine in the runtime stage, then what is the point of distributing the |
Attempting to run
go get
in the current golang:alpine image to grab thedep
command and running into the following error:Issue persists after complete container and image wipe.
Dockerfile to reproduce (for me at least :D ) :
The application being run is the hello world HTTP server for Go. I'm currently getting around this by doing an
apk update && apk install git
at the top of this file but it seemed odd that this image wouldn't have git installed by default?Thoughts?
Thanks!
The text was updated successfully, but these errors were encountered: