A tutorial for developers that want to learn about how to build modern applications on top of AWS. You will build a sample website that leverages infrastructure as code, containers, serverless code functions, CI/CD, and more.
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/aws@v1.15.77"
RUN go get -v "github.com/aws/aws-sdk-go/aws/session@v1.15.77"
RUN go get -v "github.com/aws/aws-sdk-go/service/dynamodb@v1.15.77"
RUN go get -v "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute@v1.15.77"
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
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/aws@v1.15.77" RUN go get -v "github.com/aws/aws-sdk-go/aws/session@v1.15.77" RUN go get -v "github.com/aws/aws-sdk-go/service/dynamodb@v1.15.77" RUN go get -v "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute@v1.15.77"
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"]`