Last active
November 2, 2019 05:35
-
-
Save donvito/4b6d9ac37103717714f946b90bd26f5b to your computer and use it in GitHub Desktop.
Dockerfile to build a docker image with a main.go gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.13.4 AS builder | |
ARG GIST_RAW_URL | |
RUN mkdir /app | |
RUN curl $GIST_RAW_URL --output /app/main.go | |
WORKDIR /app | |
RUN CGO_ENABLED=0 GOOS=linux go build -o main ./... | |
FROM alpine:latest AS production | |
COPY --from=builder /app . | |
CMD ["./main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello universe! test running the code from a gist!") | |
person := Person{name:"Melvin"} | |
person.sayName() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Person struct { | |
name string | |
} | |
func (person *Person) sayName() { | |
fmt.Printf("Name is %s", person.name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use:
docker build -f Dockerfile -t go-multi-stage --build-arg GIST_RAW_URL=https://gist.githubusercontent.com/donvito/4b6d9ac37103717714f946b90bd26f5b/raw/923246357e1f3aa0e97d9158566a2021a7caafcd/main.go .
docker run go-multi-stage