-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
51 lines (34 loc) · 1.26 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:alpine AS build
RUN apk add --no-cache gcc libc-dev git
WORKDIR /src/jx-cdevents-adapter
# Force the go compiler to use modules
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV BUILDFLAGS=""
ENV GOPROXY=https://proxy.golang.org
# Copy `go.mod` for definitions and `go.sum` to invalidate the next layer
# in case of a change in the dependencies
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
ARG debugBuild
# set buildflags for debug build
RUN if [ ! -z "$debugBuild" ]; then export BUILDFLAGS='-gcflags "all=-N -l"'; fi
# Copy local code to the container image.
COPY . .
# Build the command inside the container.
# (You may fetch or manage dependencies here, either manually or with a tool like "godep".)
RUN GOOS=linux go build -ldflags '-linkmode=external' $BUILDFLAGS -v -o jx-cdevents-adapter
RUN go build -o /jx-cdevents-adapter
FROM cgr.dev/chainguard/wolfi-base:latest
COPY --from=build /jx-cdevents-adapter /jx-cdevents-adapter
EXPOSE 80
# Add a new user
RUN adduser -D myuser
# Change the ownership of the binary to the new user
RUN chown myuser:myuser /jx-cdevents-adapter
# Run the binary as the new user
USER myuser
# required for external tools to detect this as a go binary
ENV GOTRACEBACK=all
ENTRYPOINT [ "./jx-cdevents-adapter" ]