Skip to content

Commit

Permalink
Use bazel rules to build docker image and push to GCR
Browse files Browse the repository at this point in the history
Using bazel to build and push image result in reproducible builds.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187252645
  • Loading branch information
jianglai committed Mar 7, 2018
1 parent 9e3fb8b commit 753a269
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 88 deletions.
22 changes: 22 additions & 0 deletions WORKSPACE
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,3 +24,25 @@ closure_repositories(
load("//java/google/registry:repositories.bzl", "domain_registry_repositories") load("//java/google/registry:repositories.bzl", "domain_registry_repositories")


domain_registry_repositories() domain_registry_repositories()

# Setup docker bazel rules
git_repository(
name = "io_bazel_rules_docker",
remote = "https://github.com/bazelbuild/rules_docker.git",
tag = "v0.4.0",
)

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_pull",
container_repositories = "repositories",
)

container_repositories()

container_pull(
name = "java_base",
registry = "gcr.io",
repository = "distroless/java",
digest = "sha256:780ee786a774a25a4485f491b3e0a21f7faed01864640af7cebec63c46a0845a",
)
27 changes: 27 additions & 0 deletions java/google/registry/proxy/BUILD
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# This package contains the code for the binary that proxies TCP traffic from # This package contains the code for the binary that proxies TCP traffic from
# the GCE/GKE to AppEngine. # the GCE/GKE to AppEngine.


load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")

package( package(
default_visibility = ["//java/google/registry:registry_project"], default_visibility = ["//java/google/registry:registry_project"],
) )
Expand Down Expand Up @@ -48,3 +50,28 @@ java_binary(
"@io_netty_tcnative", "@io_netty_tcnative",
], ],
) )

container_image(
name = "proxy_image",
base = "@java_base//image",
entrypoint = [
"java",
"-jar",
"proxy_server_deploy.jar",
],
files = [":proxy_server_deploy.jar"],
ports = [
"30000",
"30001",
"30002",
],
)

container_push(
name = "proxy_push",
format = "Docker",
image = ":proxy_image",
registry = "gcr.io",
repository = "GCP_PROJECT/IMAGE_NAME",
tag = "bazel",
)
4 changes: 2 additions & 2 deletions java/google/registry/proxy/config/default-config.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ kms:
cryptoKey: your-kms-cryptoKey cryptoKey: your-kms-cryptoKey


epp: epp:
port: 700 port: 30002
relayHost: registry-project-id.appspot.com relayHost: registry-project-id.appspot.com
relayPath: /_dr/epp relayPath: /_dr/epp


Expand Down Expand Up @@ -122,7 +122,7 @@ epp:
customQuota: [] customQuota: []


whois: whois:
port: 43 port: 30001
relayHost: registry-project-id.appspot.com relayHost: registry-project-id.appspot.com
relayPath: /_dr/whois relayPath: /_dr/whois


Expand Down
24 changes: 0 additions & 24 deletions java/google/registry/proxy/kubernetes/Dockerfile

This file was deleted.

61 changes: 0 additions & 61 deletions java/google/registry/proxy/kubernetes/build_image.sh

This file was deleted.

3 changes: 2 additions & 1 deletion java/google/registry/proxy/kubernetes/proxy-deployment.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
secretName: proxy-account secretName: proxy-account
containers: containers:
- name: proxy - name: proxy
image: INSERT_YOUR_IMAGE_NAME_HERE image: gcr.io/GCP_PROJECT/IMAGE_NAME:bazel
ports: ports:
- containerPort: 30000 - containerPort: 30000
name: health-check name: health-check
Expand All @@ -41,6 +41,7 @@ spec:
volumeMounts: volumeMounts:
- name: service-account - name: service-account
mountPath: /var/secrets/google mountPath: /var/secrets/google
imagePullPolicy: Always
args: ["--log"] args: ["--log"]
env: env:
- name: GOOGLE_APPLICATION_CREDENTIALS - name: GOOGLE_APPLICATION_CREDENTIALS
Expand Down

0 comments on commit 753a269

Please sign in to comment.