-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
51 lines (36 loc) · 1.36 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
42
43
44
45
46
47
48
49
50
51
FROM golang:1.23 AS builder_src
COPY jemalloc-install.sh .
RUN apt-get update -y
RUN apt-get install bzip2 -y
RUN bash jemalloc-install.sh
FROM builder_src AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
RUN go mod download
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Copy the source from the current directory to the Working Directory inside the container
COPY cmd ./cmd
COPY internal ./internal
COPY app.go .env-test ./
# Build the Go app with jemalloc
RUN CGO_ENABLED=1 GOOS=linux go build -pgo=cmd/datahub/default-jemalloc.pprof -ldflags="-extldflags=-static" -tags jemalloc,allocator -o server cmd/datahub/main.go
# Build the Go app with gogc
RUN CGO_ENABLED=0 GOOS=linux go build -pgo=cmd/datahub/default-gogc.pprof -o server-gogc cmd/datahub/main.go
# Run unit tests
RUN go test ./... -v
FROM alpine:latest
RUN apk update
RUN apk add --upgrade rsync
RUN apk --no-cache add ca-certificates rsync
RUN apk upgrade libssl3 libcrypto3
WORKDIR /root/
COPY --from=builder /app/server .
COPY --from=builder /app/server-gogc .
COPY --from=builder /go/bin/dlv .
# Expose port 8080 to the outside world, also 40000 for delve
EXPOSE 8080 40000
ENV GOMAXPROCS=128
CMD ["./server"]