Skip to content

Add 3.x docker images #572

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

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions images/docker/BUILD
Original file line number Diff line number Diff line change
@@ -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",
)
11 changes: 11 additions & 0 deletions images/docker/README.md
Original file line number Diff line number Diff line change
@@ -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).
3 changes: 2 additions & 1 deletion images/docker/ubuntu/BUILD → images/docker/ubuntu-2x/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -29,6 +29,7 @@ sh_binary(
checkstyle_test(
name = "checkstyle",
include = glob(["*"]),
exclude = glob(["*.md"]),
license_type = "mpl-header",
size = "small",
)
File renamed without changes.
24 changes: 24 additions & 0 deletions images/docker/ubuntu-2x/README.md
Original file line number Diff line number Diff line change
@@ -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:<target>`.

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.
13 changes: 13 additions & 0 deletions images/docker/ubuntu-3x/BUILD
Original file line number Diff line number Diff line change
@@ -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",
)
6 changes: 6 additions & 0 deletions images/docker/ubuntu-3x/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions images/docker/ubuntu-3x/Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions images/docker/ubuntu-3x/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions images/docker/ubuntu-3x/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.1
43 changes: 43 additions & 0 deletions images/docker/ubuntu-3x/assemble-deploy-all.sh
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 19 additions & 0 deletions images/docker/ubuntu-3x/assemble-docker.sh
Original file line number Diff line number Diff line change
@@ -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}"
18 changes: 18 additions & 0 deletions images/docker/ubuntu-3x/deploy-docker.sh
Original file line number Diff line number Diff line change
@@ -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}"