Last active
December 9, 2017 03:58
-
-
Save orvyl/7000f973abe88d40c8c91d4e28e139a7 to your computer and use it in GitHub Desktop.
Compile Golang project with sub packages and vendor folder. Golang + golang:alpine + Package Oriented Design
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.9-alpine | |
RUN mkdir /app | |
WORKDIR /app | |
RUN mkdir -p /go/src/github.com/your_user_name/your_app # Mimics your Golang workspace. Take note that $GOPATH = /go | |
ADD . /go/src/github.com/your_user_name/your_app # Copies all the source code of the package(your_app) including the vendor/ | |
RUN go build github.com/your_user_name/your_app/cmd/serviced # here's where my main() resides | |
RUN mv /go/src/github.com/your_user_name/your_app/cmd/serviced/config.yml /app && \ | |
rm -rf /go/src # Deletes all source code after compilation. In this case, I moved first the config file into the WORKDIR where the binary resides | |
ENV CONFIG_PATH /app # Assuming that the binary(app) will read the config file in this path | |
CMD ["./serviced"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment