drastically reduced image size by multistaging and introducing docker ignore (from ~1.6 GB to 20 MB)

main
Keegan 2 years ago
parent c2bc4ab715
commit 67bc16c5d4

@ -0,0 +1,8 @@
*
# exluding everything and only allowing directly relevant stuff
!cmd/server/main.go
!internal
!tokens
!go.mod
!go.sum
!server

3
.gitignore vendored

@ -17,9 +17,10 @@
# vendor/ # vendor/
# binaries # binaries
bin/* bin
*.tar.gz *.tar.gz
# logs # logs
*.log *.log
tokens tokens
logs

@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
FROM golang:1.18 FROM golang:1.18-alpine as builder
WORKDIR /app WORKDIR /app
@ -7,12 +7,17 @@ COPY . .
RUN go mod download RUN go mod download
RUN go build -o /server ./cmd/server/main.go RUN CGO_ENABLED=0 go build -o /server ./cmd/server/main.go
FROM alpine
COPY --from=builder /server .
COPY --from=builder /app/tokens/ ./tokens
EXPOSE 2022 EXPOSE 2022
EXPOSE 2023 EXPOSE 2023
CMD [ "/server" ] ENTRYPOINT [ "./server" ]

@ -97,7 +97,7 @@ func NewCoordinator(ip string,port int,ch chan error) *Coordinator {
c.Ip = ip c.Ip = ip
c.Port = port c.Port = port
c.hw = &hw{} c.hw = &hw{}
c.HB = time.Duration(1 * time.Second) c.HB = time.Duration(5 * time.Second)
c.PingTimer = make(chan struct{}) c.PingTimer = make(chan struct{})
// this is going to be scuffed // this is going to be scuffed
url := fmt.Sprintf("http://%s:8086",ip) url := fmt.Sprintf("http://%s:8086",ip)

Loading…
Cancel
Save