Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
change docker build process
Browse files Browse the repository at this point in the history
  • Loading branch information
srinandan committed Nov 28, 2021
1 parent d29f27e commit 5186da9
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM alpine:latest as builder
RUN addgroup -S apigee && adduser -S apigee -G apigee -u 1001
FROM golang:latest as builder
ADD ./apiclient /go/src/apigeecli/apiclient
ADD ./bundlegen /go/src/apigeecli/bundlegen
ADD ./client /go/src/apigeecli/client
ADD ./cmd /go/src/apigeecli/cmd
ADD ./clilog /go/src/apigeecli/clilog
COPY main.go /go/src/apigeecli/main.go
COPY go.mod go.sum /go/src/apigeecli/
WORKDIR /go/src/apigeecli
RUN groupadd -r -g 20000 apigee && useradd -M -u 20001 -g 0 -r -c "Default Apigee user" apigee && chown -R 20001:0 /go
ENV GO111MODULE=on
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -a -ldflags='-s -w -extldflags "-static"' -o /go/bin/apigeecli /go/src/apigeecli/main.go

#without these certificates, we cannot verify the JWT token
FROM alpine:latest as certs
RUN apk --update add ca-certificates

FROM scratch
COPY --from=builder /etc/passwd /etc/group /etc/shadow /etc/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY apigeecli /
USER apigee
COPY --from=builder /go/bin/apigeecli .
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
USER 20001
ENTRYPOINT ["/apigeecli"]

0 comments on commit 5186da9

Please sign in to comment.