diff --git a/.netrc b/.netrc new file mode 100644 index 00000000..cdd646e9 --- /dev/null +++ b/.netrc @@ -0,0 +1,7 @@ +machine github.com + login spectro-prow + password 51c3e8a896ac8d85ba13b0e48f9cd13d26e4a438 + +machine api.github.com + login spectro-prow + password 51c3e8a896ac8d85ba13b0e48f9cd13d26e4a438 \ No newline at end of file diff --git a/Makefile b/Makefile index d3f09bd0..963acdd5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ export PATH := $(GOPATH)/bin:$(PATH) export GO111MODULE=on LDFLAGS := -s -w +FRPC_IMG ?= "gcr.io/spectro-common-dev/${USER}/frpc:latest" +FRPS_IMG ?= "gcr.io/spectro-common-dev/${USER}/frps:latest" all: fmt build @@ -22,9 +24,17 @@ vet: frps: env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frps ./cmd/frps +docker-frps: + docker build . -t ${FRPS_IMG} -f build/frps/Dockerfile + docker push ${FRPS_IMG} + frpc: env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frpc ./cmd/frpc +docker-frpc: + docker build . -t ${FRPC_IMG} -f build/frpc/Dockerfile + docker push ${FRPC_IMG} + test: gotest gotest: diff --git a/build/frpc/Dockerfile b/build/frpc/Dockerfile new file mode 100644 index 00000000..832d4279 --- /dev/null +++ b/build/frpc/Dockerfile @@ -0,0 +1,27 @@ +# Build the manager binary +FROM golang:1.16 as builder + +ADD .netrc /root/.netrc + +RUN chmod 600 /root/.netrc + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY . . + +# Build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o frpc cmd/frpc/main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:latest +WORKDIR / +COPY --from=builder /workspace/frpc . +ENTRYPOINT ["/frpc"] \ No newline at end of file diff --git a/build/frps/Dockerfile b/build/frps/Dockerfile new file mode 100644 index 00000000..c206b0af --- /dev/null +++ b/build/frps/Dockerfile @@ -0,0 +1,27 @@ +# Build the manager binary +FROM golang:1.16 as builder + +ADD .netrc /root/.netrc + +RUN chmod 600 /root/.netrc + +WORKDIR /workspace +# Copy the Go Modules manifests +COPY go.mod go.mod +COPY go.sum go.sum +# cache deps before building and copying source so that we don't need to re-download as much +# and so that source changes don't invalidate our downloaded layer +RUN go mod download + +# Copy the go source +COPY . . + +# Build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o frps cmd/frps/main.go + +# Use distroless as minimal base image to package the manager binary +# Refer to https://github.com/GoogleContainerTools/distroless for more details +FROM gcr.io/distroless/static:latest +WORKDIR / +COPY --from=builder /workspace/frps . +ENTRYPOINT ["/frps"] \ No newline at end of file