-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
42 lines (31 loc) · 1.31 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
####################################################################
# Builder Stage #
####################################################################
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang:alpine AS builder
LABEL MAINTAINER="[email protected]"
# Create WORKDIR using project's root directory
WORKDIR /go/src/github.com/ong-gtp/go-chat
# Copy the local package files to the container's workspace
# in the above created WORKDIR
COPY . .
RUN apk add --no-cache git
RUN go mod tidy
# Build the API service inside the container
RUN go build -o gochatapp
#####################################################################
# Final Stage #
#####################################################################
# Pull golang alpine image (very small image, with minimum needed to run Go)
FROM alpine:3.16
RUN apk update \
&& apk upgrade
# Create WORKDIR
WORKDIR /app
# Copy app binary from the Builder stage image
COPY --from=builder /go/src/github.com/ong-gtp/go-chat/gochatapp .
# Run the gochatapp command by default when the container starts.
CMD ["./gochatapp"]
# Document that the service uses port 9010
EXPOSE 9010