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

module-2/app/Dockerfile needs golang version #249

Open
mattsinfield opened this issue Mar 13, 2021 · 1 comment
Open

module-2/app/Dockerfile needs golang version #249

mattsinfield opened this issue Mar 13, 2021 · 1 comment

Comments

@mattsinfield
Copy link

mattsinfield commented Mar 13, 2021

The Dockerfile for the Go version of this sample uses the latest version of golang:alpine which causes issues for the RUN go get -d -v command. It generates the error:

go: go.mod file not found in current directory or any parent directory; see 'go help modules'

Tie the version of golang:alpine image to a version round about the same time as this sample was created and ensure that the AWS SDK versions are from the same time from too. This prevents the error as that version of Go (presumably) doesn't have all the latest module handling in it. Change the Dockerfile to:

`FROM golang:1.15-alpine AS builder

WORKDIR /go/src/app
COPY ./service/ .

RUN echo Fetching project dependencies
RUN go mod init
RUN go get -v "github.com/aws/aws-sdk-go/[email protected]"
RUN go get -v "github.com/aws/aws-sdk-go/aws/[email protected]"
RUN go get -v "github.com/aws/aws-sdk-go/service/[email protected]"
RUN go get -v "github.com/aws/aws-sdk-go/service/dynamodb/[email protected]"

RUN echo Building and installing Mystical Mysfits Service
RUN go install -v

FROM alpine AS app
COPY --from=builder /go/bin/app /bin/app
COPY --from=builder /go/src/app/mysfits-response.json /mysfits-response.json

EXPOSE 8080

RUN echo Starting the Go service...
CMD ["app"]`

@enriquesalceda
Copy link

Thank you @mattsinfield, I had the same issue and I updated my Dockerfile with your recommendation, it works now:

... logs before...
Successfully tagged mythicalmysfits/service:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants