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

build: add support for building native API and Fuseki Docker images on Apple M1 (DEV-435) #1987

Merged
merged 2 commits into from Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
102 changes: 54 additions & 48 deletions WORKSPACE
Expand Up @@ -16,6 +16,42 @@ http_archive(
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version),
)

#####################################
# Buildifier #
#####################################
# buildifier is written in Go and hence needs rules_go to be built.
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.17.6")

http_archive(
name = "bazel_gazelle",
sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
],
)

# bazel buildtools providing buildifier
http_archive(
name = "com_github_bazelbuild_buildtools",
strip_prefix = "buildtools-master",
url = "https://github.com/bazelbuild/buildtools/archive/master.zip",
)

#####################################
# Docker #
#####################################
Expand Down Expand Up @@ -48,26 +84,25 @@ load(
"container_pull",
)

# get distroless java
# get openjdk
container_pull(
name = "java_base",
# 'tag' is also supported, but digest is encouraged for reproducibility.
digest = "sha256:deadbeef",
registry = "gcr.io",
repository = "distroless/java",
name = "openjdk11_amd64",
digest = "sha256:967349ef166d630bceda0370507b096edd6e7220e62e4539db70f04c04c2295f", # 7.01.2022
registry = "docker.io",
repository = "eclipse-temurin",
# tag = "11-jre-focal", # Ubuntu 20.04
)

# get openjdk
container_pull(
name = "openjdk11",
digest = "sha256:14605eb0f24ce726e13c4a85862325083dee3ab13da847b7af20d0df5966c176", # 29.11.2021
name = "openjdk11_arm64",
digest = "sha256:e46fac3005d08732931de9671864683f6adf3a3eb0f8a7e8ac27d1bff1955a5c", # 7.01.2022
registry = "docker.io",
repository = "eclipse-temurin",
# tag = "11-jre-focal", # Ubuntu 20.04
)

# get sipi
load("//third_party:versions.bzl", "FUSEKI_IMAGE_DIGEST", "FUSEKI_REPOSITORY", "SIPI_IMAGE_DIGEST", "SIPI_REPOSITORY")
load("//third_party:versions.bzl", "FUSEKI_IMAGE_DIGEST_AMD64", "FUSEKI_IMAGE_DIGEST_ARM64", "FUSEKI_REPOSITORY", "SIPI_IMAGE_DIGEST", "SIPI_REPOSITORY")

container_pull(
name = "sipi",
Expand All @@ -77,8 +112,15 @@ container_pull(
)

container_pull(
name = "jenafuseki",
digest = FUSEKI_IMAGE_DIGEST,
name = "jenafuseki_amd64",
digest = FUSEKI_IMAGE_DIGEST_AMD64,
registry = "docker.io",
repository = FUSEKI_REPOSITORY,
)

container_pull(
name = "jenafuseki_arm64",
digest = FUSEKI_IMAGE_DIGEST_ARM64,
registry = "docker.io",
repository = FUSEKI_REPOSITORY,
)
Expand Down Expand Up @@ -196,42 +238,6 @@ load("@twirl//:defs.bzl", twirl_pinned_maven_install = "pinned_maven_install")

twirl_pinned_maven_install()

#####################################
# Buildifier #
#####################################
# buildifier is written in Go and hence needs rules_go to be built.
# See https://github.com/bazelbuild/rules_go for the up to date setup instructions.
http_archive(
name = "io_bazel_rules_go",
sha256 = "69de5c704a05ff37862f7e0f5534d4f479418afc21806c887db544a316f3cb6b",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/v0.27.0/rules_go-v0.27.0.tar.gz",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

http_archive(
name = "bazel_gazelle",
sha256 = "b85f48fa105c4403326e9525ad2b2cc437babaa6e15a3fc0b1dbab0ab064bc7c",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.22.2/bazel-gazelle-v0.22.2.tar.gz",
],
)

# bazel buildtools providing buildifier
http_archive(
name = "com_github_bazelbuild_buildtools",
strip_prefix = "buildtools-master",
url = "https://github.com/bazelbuild/buildtools/archive/master.zip",
)

#####################################
# rules_pkg - basic packaging rules #
#####################################
Expand Down
5 changes: 4 additions & 1 deletion docker/knora-api/BUILD.bazel
Expand Up @@ -5,7 +5,10 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_image", "cont
# builds the docker image
container_image(
name = "image",
base = "@openjdk11//image",
base = select({
"@platforms//cpu:arm64": "@openjdk11_arm64//image",
"//conditions:default": "@openjdk11_amd64//image",
}),
cmd = [
"java",
"-jar",
Expand Down
6 changes: 4 additions & 2 deletions docker/knora-jena-fuseki/BUILD.bazel
Expand Up @@ -5,8 +5,10 @@ load("@io_bazel_rules_docker//container:container.bzl", "container_image", "cont
# builds the docker image
container_image(
name = "image",
base = "@jenafuseki//image",
# env = {},
base = select({
"@platforms//cpu:arm64": "@jenafuseki_arm64//image",
"//conditions:default": "@jenafuseki_amd64//image",
}),
labels = {
"MAINTAINER": "400790+subotic@users.noreply.github.com",
},
Expand Down
3 changes: 2 additions & 1 deletion third_party/versions.bzl
Expand Up @@ -16,4 +16,5 @@ SIPI_IMAGE_DIGEST = "sha256:67a0e8c16a67914f2765a1c7906e781383b835cfe72cd19c763b
FUSEKI_REPOSITORY = "daschswiss/apache-jena-fuseki"
FUSEKI_VERSION = "2.0.7" # contains Fuseki 4.3.2 (with log4j 2.16.0)
FUSEKI_IMAGE = FUSEKI_REPOSITORY
FUSEKI_IMAGE_DIGEST = "sha256:fea8c556fca76c6beab2589018babd778d55dbdffef725fd2de784646cca0638"
FUSEKI_IMAGE_DIGEST_AMD64 = "sha256:fea8c556fca76c6beab2589018babd778d55dbdffef725fd2de784646cca0638"
FUSEKI_IMAGE_DIGEST_ARM64 = "sha256:137dc481978e13ff56a7212976b2ef0d8696e08c0abf4f97a4973a2af0b77b5a"