-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.blackbox
36 lines (27 loc) · 927 Bytes
/
Dockerfile.blackbox
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
FROM golang:1.18.1-alpine3.15 AS builder
#Set necessary env vars for the image
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOFLAGS="-mod=vendor" \
GOARCH=amd64
# Move to /src directory as the place for resulting binary folder
WORKDIR /src
# Copy and download dependency using go mod
COPY go.mod go.sum ./
COPY internal internal
COPY vendor vendor
COPY test test
RUN go clean ./...
RUN CC=x86_64-linux-gnu-gcc GOOS=linux GOARCH=amd64 go test -v -c ./test/blackbox/suite_test.go -o ./dist/blackbox
# Build a small image
FROM alpine:latest
RUN apk --no-cache add ca-certificates
## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.9.0/wait /wait
RUN chmod +x /wait
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /src /src
COPY --from=builder /src/dist/blackbox /bin/blackbox
# Command to run
CMD ["/bin/blackbox"]