diff --git a/images/docker/BUILD b/images/docker/BUILD new file mode 100644 index 00000000..3e8118fa --- /dev/null +++ b/images/docker/BUILD @@ -0,0 +1,13 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +load("//tool/checkstyle:rules.bzl", "checkstyle_test") + +checkstyle_test( + name = "checkstyle", + include = glob(["*"]), + exclude = glob(["*.md"]), + license_type = "mpl-header", + size = "small", +) diff --git a/images/docker/README.md b/images/docker/README.md new file mode 100644 index 00000000..4622c866 --- /dev/null +++ b/images/docker/README.md @@ -0,0 +1,11 @@ +# TypeDB Docker Images + +TypeDB uses custom Docker images for different applications. + +These images can be created using image layers through Bazel rules (e.g., `docker_container_run_and_commit`), but we’ve +encountered OS-specific issues — presumably due to missing hidden parameters in the generated images. Additionally, we +don’t expect the base images to change frequently. Therefore, it’s more reliable to prepare them once and store them in +a separate repository. + +Currently, there are multiple Ubuntu-based images with the required dependencies for both Java-based and +Rust-based [TypeDB servers](https://github.com/typedb/typedb). diff --git a/images/docker/ubuntu/BUILD b/images/docker/ubuntu-2x/BUILD similarity index 89% rename from images/docker/ubuntu/BUILD rename to images/docker/ubuntu-2x/BUILD index 8894f72a..32a381b3 100644 --- a/images/docker/ubuntu/BUILD +++ b/images/docker/ubuntu-2x/BUILD @@ -3,7 +3,7 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. -load("//images/docker/ubuntu:deployment.bzl", deployment_docker = "deployment") +load("//images/docker/ubuntu-2x:deployment.bzl", deployment_docker = "deployment") load("//tool/checkstyle:rules.bzl", "checkstyle_test") sh_library( @@ -29,6 +29,7 @@ sh_binary( checkstyle_test( name = "checkstyle", include = glob(["*"]), + exclude = glob(["*.md"]), license_type = "mpl-header", size = "small", ) diff --git a/images/docker/ubuntu/Dockerfile b/images/docker/ubuntu-2x/Dockerfile similarity index 100% rename from images/docker/ubuntu/Dockerfile rename to images/docker/ubuntu-2x/Dockerfile diff --git a/images/docker/ubuntu-2x/README.md b/images/docker/ubuntu-2x/README.md new file mode 100644 index 00000000..8819306c --- /dev/null +++ b/images/docker/ubuntu-2x/README.md @@ -0,0 +1,24 @@ +# TypeDB Ubuntu 2.x Images + +These images are prepared for TypeDB 2.x and contain all the required dependencies like JVM. + +Images are tagged based on the current Git commit SHA. + +## Usage + +### Setup + +Images are assembled and deployed from local machines with [Docker](https://www.docker.com/get-started/). + +To authenticate before starting the work, use: + +```shell +docker login +``` + +### Execution + +Using a suitable OS and architecture, use `bazel run //images/docker/ubuntu-2x:`. + +If Bazel rules do not work on your machine, run `assemble-docker.sh` and `deploy-docker.sh` manually, providing all the required arguments. See `BUILD` for +passed arguments examples. diff --git a/images/docker/ubuntu/assemble-docker.sh b/images/docker/ubuntu-2x/assemble-docker.sh similarity index 100% rename from images/docker/ubuntu/assemble-docker.sh rename to images/docker/ubuntu-2x/assemble-docker.sh diff --git a/images/docker/ubuntu/deploy-docker.sh b/images/docker/ubuntu-2x/deploy-docker.sh similarity index 100% rename from images/docker/ubuntu/deploy-docker.sh rename to images/docker/ubuntu-2x/deploy-docker.sh diff --git a/images/docker/ubuntu/deployment.bzl b/images/docker/ubuntu-2x/deployment.bzl similarity index 100% rename from images/docker/ubuntu/deployment.bzl rename to images/docker/ubuntu-2x/deployment.bzl diff --git a/images/docker/ubuntu/version-docker.sh b/images/docker/ubuntu-2x/version-docker.sh similarity index 100% rename from images/docker/ubuntu/version-docker.sh rename to images/docker/ubuntu-2x/version-docker.sh diff --git a/images/docker/ubuntu-3x/BUILD b/images/docker/ubuntu-3x/BUILD new file mode 100644 index 00000000..e4304dd8 --- /dev/null +++ b/images/docker/ubuntu-3x/BUILD @@ -0,0 +1,13 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +load("//tool/checkstyle:rules.bzl", "checkstyle_test") + +checkstyle_test( + name = "checkstyle", + include = glob(["*"]), + exclude = glob(["*.md", "VERSION"]), + license_type = "mpl-header", + size = "small", +) diff --git a/images/docker/ubuntu-3x/Dockerfile.amd64 b/images/docker/ubuntu-3x/Dockerfile.amd64 new file mode 100644 index 00000000..d36e00ac --- /dev/null +++ b/images/docker/ubuntu-3x/Dockerfile.amd64 @@ -0,0 +1,6 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +FROM ubuntu@sha256:3d1556a8a18cf5307b121e0a98e93f1ddf1f3f8e092f1fddfd941254785b95d7 +RUN apt-get -y update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists diff --git a/images/docker/ubuntu-3x/Dockerfile.arm64 b/images/docker/ubuntu-3x/Dockerfile.arm64 new file mode 100644 index 00000000..71efaa23 --- /dev/null +++ b/images/docker/ubuntu-3x/Dockerfile.arm64 @@ -0,0 +1,6 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +FROM ubuntu@sha256:7c75ab2b0567edbb9d4834a2c51e462ebd709740d1f2c40bcd23c56e974fe2a8 +RUN apt-get -y update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists diff --git a/images/docker/ubuntu-3x/README.md b/images/docker/ubuntu-3x/README.md new file mode 100644 index 00000000..a447a62c --- /dev/null +++ b/images/docker/ubuntu-3x/README.md @@ -0,0 +1,56 @@ +# TypeDB Ubuntu 3.x Images + +These images are prepared for TypeDB 3.x and contain a default SSL configuration. + +Images are prepared for two base architectures: `arm64` and `amd64`. For easier maintenance, the images are tagged based +on the incremental version specified manually in the `VERSION` file. + +## Usage + +For simplicity and due to the current usage of these scripts, there is no Bazel integration provided. + +It's possible to build images of any architecture on a local machine (e.g., it's successfully tested on a arm-based +Mac). + +### Setup + +Images are assembled and deployed from local machines with [Docker](https://www.docker.com/get-started/). + +To authenticate before starting the work, use: + +```shell +docker login +``` + +If platform-specific images use `buildx`, run: + +```shell +docker buildx create --use --name multiarch-builder +docker buildx inspect --bootstrap + +# If the previous command fails, run this cleanup and try again: +# docker buildx rm multiarch-builder +``` + +### Execution + +Update `VERSION`. For better maintenance, set the TypeDB server's version expected to use this image first. +Follow one of the branches below based on your goals. + +#### Assembly and publish all architectures + +To update all images via a single line, run: + +```shell +./assemble-deploy-all.sh +``` + +This script automatically assembles and publishes all platform-specific images with a multi-arch image. + +Note that there is no `latest` tag preparation as multiple Ubuntu image versions can be supported in parallel for +different purposes. + +#### Separate steps + +Use `assemble-docker.sh` and `deploy-docker.sh` separately if needed. See comments and `assemble-deploy-all.sh` for +usage examples. diff --git a/images/docker/ubuntu-3x/VERSION b/images/docker/ubuntu-3x/VERSION new file mode 100644 index 00000000..13d683cc --- /dev/null +++ b/images/docker/ubuntu-3x/VERSION @@ -0,0 +1 @@ +3.0.1 \ No newline at end of file diff --git a/images/docker/ubuntu-3x/assemble-deploy-all.sh b/images/docker/ubuntu-3x/assemble-deploy-all.sh new file mode 100755 index 00000000..2f8e7223 --- /dev/null +++ b/images/docker/ubuntu-3x/assemble-deploy-all.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +set -ex + +# Usage: ./assemble-deploy-all.sh + +VERSION_FILE="./VERSION" + +if [[ ! -f "${VERSION_FILE}" ]]; then + echo "VERSION file not found" + exit 1 +fi + +VERSION=$(<"$VERSION_FILE") +VERSION=$(echo "$VERSION" | tr -d '[:space:]') + +if [[ -z "$VERSION" ]]; then + echo "VERSION file is invalid" + exit 1 +fi + +echo "Preparing images for version ${VERSION}" + +DOCKER_ORG=typedb +DOCKER_REPO=ubuntu +PLATFORMS=("amd64" "arm64") # Update `docker manifest` commands below if it's changed + +for ARCH in "${PLATFORMS[@]}"; do + ./assemble-docker.sh "Dockerfile.${ARCH}" "${ARCH}" "${VERSION}" "${DOCKER_ORG}" "${DOCKER_REPO}" + ./deploy-docker.sh "${ARCH}" "${VERSION}" "${DOCKER_ORG}" "${DOCKER_REPO}" +done + +TAG="${DOCKER_ORG}/${DOCKER_REPO}:${VERSION}" +echo "Creating ${TAG} multi-arch manifest" +docker manifest create "${TAG}" \ + --amend "${TAG}-amd64" \ + --amend "${TAG}-arm64" +docker manifest push "${TAG}" + +echo "Success" diff --git a/images/docker/ubuntu-3x/assemble-docker.sh b/images/docker/ubuntu-3x/assemble-docker.sh new file mode 100755 index 00000000..69ec86ec --- /dev/null +++ b/images/docker/ubuntu-3x/assemble-docker.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +set -ex + +# Usage: ./assemble-docker.sh Dockerfile.amd64 amd64 3.1.0 typedb ubuntu + +DOCKERFILE=$1 +PLATFORM=$2 +DOCKER_VERSION=$3 +DOCKER_ORG=$4 +DOCKER_REPO=$5 +TAG="${DOCKER_ORG}/${DOCKER_REPO}:${DOCKER_VERSION}-${PLATFORM}" + +echo "Assembling image for ${PLATFORM}: ${TAG}" +docker buildx build --platform "linux/${PLATFORM}" --load -f "${DOCKERFILE}" -t "${TAG}" . +echo "Successfully assembled ${TAG}" diff --git a/images/docker/ubuntu-3x/deploy-docker.sh b/images/docker/ubuntu-3x/deploy-docker.sh new file mode 100755 index 00000000..8668c124 --- /dev/null +++ b/images/docker/ubuntu-3x/deploy-docker.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +set -ex + +# Usage: ./deploy-docker.sh amd64 3.1.0 typedb ubuntu + +PLATFORM=$1 +DOCKER_VERSION=$2 +DOCKER_ORG=$3 +DOCKER_REPO=$4 +TAG="${DOCKER_ORG}/${DOCKER_REPO}:${DOCKER_VERSION}-${PLATFORM}" + +echo "Deploying image for ${PLATFORM}: ${TAG}" +docker push "${TAG}" +echo "Successfully pushed ${TAG}"