Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker for golang application

Tags:

docker

go

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 .

like image 618
Jenny Hilton Avatar asked Jun 05 '18 19:06

Jenny Hilton


People also ask

How to create a dockerfile for your Golang application?

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.

How do I create Docker images for Go applications?

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).

Does phpMyAdmin run with Golang-Docker?

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.

What is a dockerfile and how to create one?

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.


1 Answers

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
like image 97
Jack Avatar answered Oct 20 '22 23:10

Jack