added frps and frpc dockerfile

This commit is contained in:
Piyush Kumar 2022-05-19 00:10:48 +05:30 committed by root
parent 9124605924
commit c0ec34c3f9
4 changed files with 71 additions and 0 deletions

7
.netrc Normal file
View File

@ -0,0 +1,7 @@
machine github.com
login spectro-prow
password 51c3e8a896ac8d85ba13b0e48f9cd13d26e4a438
machine api.github.com
login spectro-prow
password 51c3e8a896ac8d85ba13b0e48f9cd13d26e4a438

View File

@ -1,6 +1,8 @@
export PATH := $(GOPATH)/bin:$(PATH) export PATH := $(GOPATH)/bin:$(PATH)
export GO111MODULE=on export GO111MODULE=on
LDFLAGS := -s -w 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 all: fmt build
@ -22,9 +24,17 @@ vet:
frps: frps:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frps ./cmd/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: frpc:
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frpc ./cmd/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 test: gotest
gotest: gotest:

27
build/frpc/Dockerfile Normal file
View File

@ -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"]

27
build/frps/Dockerfile Normal file
View File

@ -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"]