add docker-compose.yml
This commit is contained in:
parent
f7b222b7f3
commit
32abb2ac26
5 changed files with 117 additions and 58 deletions
31
Dockerfile
31
Dockerfile
|
|
@ -1,19 +1,26 @@
|
|||
FROM golang:alpine AS builder
|
||||
FROM golang AS builder
|
||||
|
||||
WORKDIR /src
|
||||
# Download dependencies
|
||||
COPY go.mod go.sum /
|
||||
RUN go mod download
|
||||
|
||||
# Add source code
|
||||
ADD ./ /go/src/github.com/dhax/go-base/
|
||||
|
||||
RUN cd /go/src/github.com/dhax/go-base && \
|
||||
go build && \
|
||||
mv ./go-base /usr/bin/go-base
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 go build -o main .
|
||||
|
||||
# Multi-Stage production build
|
||||
FROM alpine
|
||||
|
||||
RUN apk add --update ca-certificates
|
||||
FROM alpine AS production
|
||||
RUN apk --no-cache add ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
# Retrieve the binary from the previous stage
|
||||
COPY --from=builder /usr/bin/go-base /usr/local/bin/go-base
|
||||
|
||||
COPY --from=builder /src/main .
|
||||
# Copy static template files
|
||||
COPY templates templates
|
||||
# Copy frontend
|
||||
COPY public public
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
# Set the binary as the entrypoint of the container
|
||||
CMD ["go-base", "serve"]
|
||||
CMD ["./main", "serve"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue