Created
September 15, 2019 09:22
-
-
Save cosmin-harangus/81d4e3b84dbf46fb9b1e254efc1586f5 to your computer and use it in GitHub Desktop.
Go: Docker file to auto rebuild app
This file contains 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 as build | |
RUN mkdir -p /build/app | |
WORKDIR /build/app/ | |
# Force the go compiler to use modules | |
ENV GO111MODULE=on | |
# We want to populate the module cache based on the go.{mod,sum} files. | |
COPY go.mod . | |
# This is the ‘magic’ step that will download all the dependencies that are specified in | |
# the go.mod and go.sum file. | |
# Because of how the layer caching system works in Docker, the go mod download | |
# command will _ only_ be re-run when the go.mod or go.sum file change | |
# (or when we add another docker instruction below this line) | |
RUN go mod download | |
# Add code refresh package | |
RUN go get github.com/cespare/reflex | |
RUN echo "-r '(\.go$|go\.mod)' -s -- sh -c 'go run . start'" >> /reflex.conf | |
ENTRYPOINT ["reflex", "--decoration=none", "-c", "/reflex.conf"] | |
COPY . . | |
# RUN CGO_ENABLED=0 go build -a -installsuffix cgo --ldflags "-s -w" -o /usr/bin/app | |
EXPOSE 80 | |
ENV PORT 80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment