i've golang application which I want to build docker image for it
the application folder called cloud-native-go
and the dockerfile is under the root project
Any idea what is wrong here ?
FROM golang:alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000
The error is :
Step 5/12 : RUN go-wrapper download # "go get -d -v ./..."
---> Running in 70c2e00f332d
/bin/sh: go-wrapper: not found
i Build it with
docker build -t cloud-native-go:1.0.0 .
We need to create a Dockerfile for our GoLang application. Simply create a file in the project directory called Dockerfile. This name is preferred since it clearly tells what it does. The docker file is a set of instructions that we telling docker to do when running that application.
Especially with Go applications, the recommended way to create Docker images is with multi-stage builds. This makes the resulting Docker image as compact as possible. You can also embed unit tests in the Docker creation process, which guarantee the correctness of image (integration tests are best kept in the pipeline).
Our Golang Application runs with success. And if we visit 8081 on our local system. phpMyAdmin runs with our database golang-docker already created. Currently, even if we change our golang code, that is not going to be reflected in the server.
A Dockerfile is a text document that contains the instructions to assemble a Docker image. When we tell Docker to build our image by executing the docker build command, Docker reads these instructions, executes them, and creates a Docker image as a result. Let’s walk through the process of creating a Dockerfile for our application.
go-wrapper
has been deprecated and removed from the images using go
version 10 and above. See here.
If you are fine using go v1.9
you can use the following image: golang:1.9.6-alpine3.7
.
So your Dockerfile
will be:
FROM golang:1.9.6-alpine3.7
WORKDIR /go/src/app
COPY . .
RUN apk add --no-cache git
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
#final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app
ENTRYPOINT ./app
LABEL Name=cloud-native-go Version=0.0.1
EXPOSE 3000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With