-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (27 loc) · 883 Bytes
/
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
# --- Stage 1:
FROM golang:1.19-alpine as builder
# Args & ENVs
ENV BUILD_PATH=/go/src/github.com/bandgren/classified-ads
RUN apk update && apk add --no-cache curl gcc git libc-dev
# COPY local files
WORKDIR ${BUILD_PATH}
COPY . .
# Get go dependencies
RUN go mod download
# revive (go lint successor)
RUN go install github.com/mgechev/revive@latest && \
revive ./...
# gosec - Golang Security Checker
RUN curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b ${GOPATH}/bin latest && \
gosec ./...
RUN go build -o service
RUN cp ${BUILD_PATH}/service /bin/service
# --- Stage 2:
FROM alpine:3
# Install dependencies
RUN apk update && apk add --no-cache ca-certificates tzdata libc6-compat
# Copy binary from builder
COPY --from=builder /bin/service /service
# Run the application on container startup.
CMD ["/service"]
EXPOSE 8000