docker build -t go-cobra .
name=${PWD##*/}
pkg="github.com/xslim/${name}"
workdir="/go/src/${pkg}"
docker run -it --rm -v "$PWD":${workdir} -w ${workdir} go-cobra build -v
#!/bin/sh | |
name=${PWD##*/} | |
# pkg="github.com/xslim/${name}" | |
# workdir="/go/src/${pkg}" | |
# image="golang" | |
# image="go-cobra" | |
# docker run -it --rm -v "$PWD":${workdir} -w ${workdir} ${image} $@ | |
env="-e GOOS=darwin -e GOARCH=amd64" | |
cache="-v go_cache:/root/.cache/go-build" | |
docker run -it --rm ${cache} -v "$PWD":/app -w /app ${env} golang:alpine go build -v |
FROM golang:alpine | |
LABEL maintainer Taras Kalapun <t.kalapun@gmail.com> | |
RUN apk add --no-cache git | |
RUN go get -u github.com/spf13/cobra | |
RUN go get -u github.com/spf13/viper | |
RUN go get -u github.com/mitchellh/go-homedir | |
ENV GOOS=darwin | |
ENV GOARCH=amd64 | |
ENTRYPOINT ["go"] | |
CMD ["--help"] |
package main | |
import "fmt" | |
func main() { | |
fmt.Println("hello world") | |
} |