Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
dipjyotimetia committed Jun 27, 2020
1 parent e87ec71 commit f481a20
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.14 as builder

# Create and change to the app directory.
WORKDIR /app

# Retrieve application dependencies using go modules.
# Allows container builds to reuse downloaded dependencies.
COPY go.* ./
COPY go.mod ./
COPY go.sum ./
COPY .env ./
COPY database.env ./

RUN go mod download

# Copy local code to the container image.
COPY . ./

RUN CGO_ENABLED=0 go test -v

# Build the binary.
# -mod=readonly ensures immutable go.mod and go.sum in container builds.
RUN CGO_ENABLED=0 GOOS=linux go build -mod=readonly -v -o server

# Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3
RUN apk add --no-cache ca-certificates

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/server /server

EXPOSE 8082

# Run the web service on container startup.
CMD ["/server"]

0 comments on commit f481a20

Please sign in to comment.