Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure support #4

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ build:instance_gcp --@google_privacysandbox_servers_common//:instance=gcp
build:instance_aws --//:instance=aws
build:instance_aws --@google_privacysandbox_servers_common//:instance=aws

build:instance_azure --//:instance=azure
build:instance_azure --@google_privacysandbox_servers_common//:instance=azure

build:platform_local --//:platform=local

build:platform_aws --//:platform=aws
Expand All @@ -40,12 +43,18 @@ build:platform_aws --@google_privacysandbox_servers_common//:platform=aws
build:platform_gcp --//:platform=gcp
build:platform_gcp --@google_privacysandbox_servers_common//:platform=gcp

build:platform_azure --//:platform=azure
build:platform_azure --@google_privacysandbox_servers_common//:platform=azure

build:local_aws --config=instance_local
build:local_aws --config=platform_aws

build:local_gcp --config=instance_local
build:local_gcp --config=platform_gcp

build:local_azure --config=instance_local
build:local_azure --config=platform_azure

build:gcp_gcp --config=instance_gcp
build:gcp_gcp --config=platform_gcp

Expand All @@ -55,6 +64,9 @@ build:local_local --config=platform_local
build:aws_aws --config=instance_aws
build:aws_aws --config=platform_aws

build:azure_azure --config=instance_azure
build:azure_azure --config=platform_azure

build:non_prod --//:build_flavor=non_prod
build:non_prod --@google_privacysandbox_servers_common//:build_flavor=non_prod
build:prod --//:build_flavor=prod
Expand Down
4 changes: 3 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2022 Google LLC
# Copyright (C) Microsoft Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,8 +21,9 @@ string_flag(
name = "instance",
build_setting_default = "aws",
values = [
"gcp",
"aws",
"azure",
"gcp",
"local",
],
)
Expand Down
120 changes: 120 additions & 0 deletions production/packaging/azure/auction_service/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Portions Copyright (c) Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
"container_layer",
)
load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_attributes",
"pkg_files",
)
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:config.bzl", "LOG_ENV_VARS")

pkg_files(
name = "server_executables",
srcs = [
"bin/init_server_basic",
"//services/auction_service:server",
],
attributes = pkg_attributes(mode = "0555"),
prefix = "/server/bin",
)

server_binaries = [
":server_executables",
]

pkg_zip(
name = "server_binaries",
srcs = server_binaries,
)

pkg_tar(
name = "server_binaries_tar",
srcs = server_binaries,
)

container_layer(
name = "server_binary_layer",
directory = "/",
tars = [
":server_binaries_tar",
],
)

container_image(
name = "server_docker_image",
base = select({
"@platforms//cpu:arm64": "@runtime-cc-debian-arm64//image",
"@platforms//cpu:x86_64": "@runtime-cc-debian-amd64//image",
}),
cmd = [
"/server/bin/init_server_basic",
],
entrypoint = ["sh"],
env = LOG_ENV_VARS,
labels = {"tee.launch_policy.log_redirect": "always"},
layers = [
":server_binary_layer",
],
ports = ["50051"],
)

container_test(
name = "structure_test",
size = "large",
configs = ["test/structure.yaml"],
driver = "tar",
image = ":server_docker_image",
)

container_test(
name = "commands_test",
size = "large",
configs = ["test/commands.yaml"],
driver = "docker",
image = ":server_docker_image",
)

# server artifacts
pkg_zip(
name = "server_artifacts",
srcs = server_binaries,
)

genrule(
name = "copy_to_dist",
srcs = [
":server_artifacts",
":server_docker_image.tar",
"//api:bidding_auction_servers_descriptor_set",
],
outs = ["copy_to_dist.bin"],
cmd_bash = """cat << EOF > '$@'
mkdir -p dist/debian
cp $(execpath :server_artifacts) dist/debian/$$(basename $(RULEDIR))_artifacts.zip
cp $(execpath :server_docker_image.tar) dist/debian/$$(basename $(RULEDIR))_image.tar
cp $(execpath //api:bidding_auction_servers_descriptor_set) dist
builders/tools/normalize-dist
EOF""",
executable = True,
local = True,
message = "copying server artifacts to dist/debian directory",
)
23 changes: 23 additions & 0 deletions production/packaging/azure/auction_service/bin/init_server_basic
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/busybox/sh
# Portions Copyright (c) Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -x
export GLOG_logtostderr=1
export GLOG_stderrthreshold=0
export GRPC_DNS_RESOLVER=native

# Start the server first.
/server/bin/server --init_config_client=true
24 changes: 24 additions & 0 deletions production/packaging/azure/auction_service/test/commands.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Portions Copyright (c) Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to docs at https://github.com/GoogleContainerTools/container-structure-test

schemaVersion: 2.0.0

# command tests require the docker toolchain
commandTests:
- name: "server help"
command: "/server/bin/server"
args: ["--help"]
exitCode: 1
35 changes: 35 additions & 0 deletions production/packaging/azure/auction_service/test/structure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Portions Copyright (c) Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# refer to docs at https://github.com/GoogleContainerTools/container-structure-test

schemaVersion: 2.0.0

fileExistenceTests:
- name: init_server_basic
path: /server/bin/init_server_basic
shouldExist: true
isExecutableBy: any

- name: server
path: /server/bin/server
shouldExist: true
isExecutableBy: any

- name: ca-certs
path: /etc/ssl/certs/ca-certificates.crt
shouldExist: true

licenseTests:
- debian: true
120 changes: 120 additions & 0 deletions production/packaging/azure/bidding_service/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Portions Copyright (c) Microsoft Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_image",
"container_layer",
)
load("@io_bazel_rules_docker//contrib:test.bzl", "container_test")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_attributes",
"pkg_files",
)
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:config.bzl", "LOG_ENV_VARS")

pkg_files(
name = "server_executables",
srcs = [
"bin/init_server_basic",
"//services/bidding_service:server",
],
attributes = pkg_attributes(mode = "0555"),
prefix = "/server/bin",
)

server_binaries = [
":server_executables",
]

pkg_zip(
name = "server_binaries",
srcs = server_binaries,
)

pkg_tar(
name = "server_binaries_tar",
srcs = server_binaries,
)

container_layer(
name = "server_binary_layer",
directory = "/",
tars = [
":server_binaries_tar",
],
)

container_image(
name = "server_docker_image",
base = select({
"@platforms//cpu:arm64": "@runtime-cc-debian-arm64//image",
"@platforms//cpu:x86_64": "@runtime-cc-debian-amd64//image",
}),
cmd = [
"/server/bin/init_server_basic",
],
entrypoint = ["sh"],
env = LOG_ENV_VARS,
labels = {"tee.launch_policy.log_redirect": "always"},
layers = [
":server_binary_layer",
],
ports = ["50051"],
)

container_test(
name = "structure_test",
size = "large",
configs = ["test/structure.yaml"],
driver = "tar",
image = ":server_docker_image",
)

container_test(
name = "commands_test",
size = "large",
configs = ["test/commands.yaml"],
driver = "docker",
image = ":server_docker_image",
)

# server artifacts
pkg_zip(
name = "server_artifacts",
srcs = server_binaries,
)

genrule(
name = "copy_to_dist",
srcs = [
":server_artifacts",
":server_docker_image.tar",
"//api:bidding_auction_servers_descriptor_set",
],
outs = ["copy_to_dist.bin"],
cmd_bash = """cat << EOF > '$@'
mkdir -p dist/debian
cp $(execpath :server_artifacts) dist/debian/$$(basename $(RULEDIR))_artifacts.zip
cp $(execpath :server_docker_image.tar) dist/debian/$$(basename $(RULEDIR))_image.tar
cp $(execpath //api:bidding_auction_servers_descriptor_set) dist
builders/tools/normalize-dist
EOF""",
executable = True,
local = True,
message = "copying server artifacts to dist/debian directory",
)
Loading