Skip to content

Commit fab277e

Browse files
committed
Adding basic image generation targets.
Factored in feedback from mcrute.
1 parent 5791bad commit fab277e

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
.PHONY: gen clean certs build
15+
.PHONY: gen clean certs build docker/proxy-server docker/proxy-agent
1616
proto/agent/agent.pb.go: proto/agent/agent.proto
1717
protoc -I proto proto/agent/agent.proto --go_out=plugins=grpc:proto
1818

@@ -32,9 +32,19 @@ proto/proxy.pb.go: proto/proxy.proto
3232
bin/proxy-agent: bin cmd/agent/main.go proto/agent/agent.pb.go
3333
go build -o bin/proxy-agent cmd/agent/main.go
3434

35+
docker/proxy-agent: cmd/agent/main.go proto/agent/agent.pb.go
36+
@[ "${REGISTRY}" ] || ( echo "REGISTRY is not set"; exit 1 )
37+
@[ "${PROJECT_ID}" ] || ( echo "PROJECT_ID is not set"; exit 1 )
38+
docker build . -f artifacts/images/agent-build.Dockerfile -t ${REGISTRY}/${PROJECT_ID}/proxy-agent:latest
39+
3540
bin/proxy-server: bin cmd/proxy/main.go proto/agent/agent.pb.go proto/proxy.pb.go
3641
go build -o bin/proxy-server cmd/proxy/main.go
3742

43+
docker/proxy-server: cmd/proxy/main.go proto/agent/agent.pb.go proto/proxy.pb.go
44+
@[ "${REGISTRY}" ] || ( echo "REGISTRY is not set"; exit 1 )
45+
@[ "${PROJECT_ID}" ] || ( echo "PROJECT_ID is not set"; exit 1 )
46+
docker build . -f artifacts/images/server-build.Dockerfile -t ${REGISTRY}/${PROJECT_ID}/server-proxy:latest
47+
3848
bin/proxy-test-client: bin cmd/client/main.go proto/proxy.pb.go
3949
go build -o bin/proxy-test-client cmd/client/main.go
4050

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@ Participation in the Kubernetes community is governed by the [Kubernetes Code of
1717

1818
## Build
1919

20+
Please make sure you have the REGISTRY and PROJECT_ID environment variables set.
21+
For local builds these can be set to anything.
22+
For image builds these determine the location of your image.
23+
For GCE the registry should be gcr.io and PROJECT_ID should be the project you
24+
want to use the images in.
25+
26+
### Local builds
27+
2028
```console
2129
make clean
2230
make certs
2331
make build
2432
```
2533

34+
### Build images
35+
36+
```console
37+
build docker/proxy-server
38+
build docker/proxy-agent
39+
```
40+
2641
## Examples
2742

2843
The current examples run two actual services as well as a sample client on one end and a sample destination for
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build the proxy-agent binary
2+
FROM golang:1.12.1 as builder
3+
4+
# Copy in the go src
5+
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
6+
COPY pkg/ pkg/
7+
COPY cmd/ cmd/
8+
COPY proto/ proto/
9+
COPY vendor/ vendor/
10+
11+
# Build
12+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o proxy-agent sigs.k8s.io/apiserver-network-proxy/cmd/agent
13+
14+
# Copy the loader into a thin image
15+
FROM scratch
16+
WORKDIR /
17+
COPY --from=builder /go/src/sigs.k8s.io/apiserver-network-proxy/proxy-agent .
18+
ENTRYPOINT ["/proxy-agent"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build the proxy-server binary
2+
FROM golang:1.12.1 as builder
3+
4+
# Copy in the go src
5+
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy
6+
COPY pkg/ pkg/
7+
COPY cmd/ cmd/
8+
COPY proto/ proto/
9+
COPY vendor/ vendor/
10+
11+
# Build
12+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o proxy-server sigs.k8s.io/apiserver-network-proxy/cmd/proxy
13+
14+
# Copy the loader into a thin image
15+
FROM scratch
16+
WORKDIR /
17+
COPY --from=builder /go/src/sigs.k8s.io/apiserver-network-proxy/proxy-server .
18+
ENTRYPOINT ["/proxy-server"]

0 commit comments

Comments
 (0)