Skip to content

Commit ab777bf

Browse files
Add 3.x docker images (#572)
## Usage and product changes Add a base Ubuntu image with CA certificates preinstalled for TypeDB 3.x. ## Motivation TypeDB Docker image required a stable base image with [CA certificates](typedb/typedb#7414). ## Implementation Split Ubuntu images into `2.x` (the old image with JVM) and `3.x`. Introduce a `VERSION` file for the images to easily match multiple arch-specific images and the TypeDB Server requiring it. Other reasoning for decisions is described in `README`s. Now, to update all 3.x images, except for the environment setup, you can just update the `VERSION` file locally and run a single script, which will do the whole work. --------- Co-authored-by: Krishnan Govindraj <[email protected]>
1 parent b92f473 commit ab777bf

17 files changed

+285
-51
lines changed

images/docker/BUILD

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
load("//tool/checkstyle:rules.bzl", "checkstyle_test")
6+
exports_files(["assemble-docker.sh", "deploy-docker.sh"])
7+
8+
checkstyle_test(
9+
name = "checkstyle",
10+
include = glob(["*"]),
11+
exclude = glob(["*.md"]),
12+
license_type = "mpl-header",
13+
size = "small",
14+
)

images/docker/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TypeDB Docker Images
2+
3+
TypeDB uses custom Docker images for different applications.
4+
5+
These images can be created using image layers through Bazel rules (e.g., `docker_container_run_and_commit`), but we’ve
6+
encountered OS-specific issues — presumably due to missing hidden parameters in the generated images. Additionally, we
7+
don’t expect the base images to change frequently. Therefore, it’s more reliable to prepare them once and store them in
8+
a separate repository.
9+
10+
Currently, there are multiple Ubuntu-based images with the required dependencies for both Java-based and
11+
Rust-based [TypeDB servers](https://github.com/typedb/typedb).

images/docker/assemble-docker.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
set -ex
7+
8+
# Usage: ./assemble-docker.sh Dockerfile.amd64 amd64 3.1.0 typedb ubuntu
9+
10+
DOCKERFILE=$(realpath $1)
11+
PLATFORM=$2
12+
TAG=$(cat $3)
13+
DOCKER_ORG=$4
14+
DOCKER_REPO=$5
15+
FULL_TAG="${DOCKER_ORG}/${DOCKER_REPO}:${TAG}"
16+
echo "Assembling image for ${PLATFORM}: ${FULL_TAG}"
17+
docker buildx build --platform "linux/${PLATFORM}" --load -f $DOCKERFILE -t "${FULL_TAG}" .
18+
echo "Successfully assembled ${FULL_TAG}"

images/docker/ubuntu/deploy-docker.sh renamed to images/docker/deploy-docker.sh

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
# License, v. 2.0. If a copy of the MPL was not distributed with this
44
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
55

6-
76
set -ex
87

9-
DOCKER_VERSION_LIB=$1
10-
DOCKER_VERSION=`$DOCKER_VERSION_LIB`
8+
# Usage: ./deploy-docker.sh amd64 3.1.0 typedb ubuntu
9+
10+
TAG=$(cat $1)
1111
DOCKER_ORG=$2
1212
DOCKER_REPO=$3
13+
TAG="${DOCKER_ORG}/${DOCKER_REPO}:${TAG}"
1314

14-
docker push $DOCKER_ORG/$DOCKER_REPO:$DOCKER_VERSION
15+
echo "Deploying image: ${TAG}"
16+
docker push "${TAG}"
17+
echo "Successfully pushed ${TAG}"

images/docker/ubuntu-2x/BUILD

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
6+
load("//images/docker/ubuntu-2x:deployment.bzl", deployment_docker = "deployment")
7+
load("//tool/checkstyle:rules.bzl", "checkstyle_test")
8+
9+
# Gen-rules to generate <VERSION>-<PLATFORM> as tag
10+
genrule(
11+
name = "tag-amd64",
12+
srcs = [":VERSION"],
13+
outs = ["tag-amd64.txt"],
14+
cmd = "cat $(location :VERSION) | tr -d '\n' > $(location tag-amd64.txt) && echo \"-amd64\" >> $(location tag-amd64.txt)",
15+
)
16+
17+
genrule(
18+
name = "tag-arm64",
19+
srcs = [":VERSION"],
20+
outs = ["tag-arm64.txt"],
21+
cmd = "cat $(location :VERSION) | tr -d '\n' > $(location tag-arm64.txt) && echo \"-arm64\" >> $(location tag-arm64.txt)",
22+
)
23+
24+
sh_binary(
25+
name = "assemble-docker-amd64",
26+
srcs = ["//images/docker:assemble-docker.sh"],
27+
data = ["Dockerfile.amd64", "VERSION", "tag-amd64"],
28+
deps = [":tag-amd64"],
29+
args = ["$(location Dockerfile.amd64)", "amd64", "$(location :tag-amd64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
30+
)
31+
32+
sh_binary(
33+
name = "assemble-docker-arm64",
34+
srcs = ["//images/docker:assemble-docker.sh"],
35+
data = ["Dockerfile.arm64", "VERSION", "tag-arm64"],
36+
deps = [":tag-arm64"],
37+
args = ["$(location Dockerfile.arm64)", "arm64", "$(location :tag-arm64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
38+
)
39+
40+
sh_binary(
41+
name = "deploy-docker-amd64",
42+
deps = [],
43+
srcs = ["//images/docker:deploy-docker.sh"],
44+
data = ["VERSION", "tag-amd64"],
45+
args = ["$(location :tag-amd64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
46+
)
47+
48+
sh_binary(
49+
name = "deploy-docker-arm64",
50+
deps = [],
51+
srcs = ["//images/docker:deploy-docker.sh"],
52+
data = ["VERSION", "tag-arm64"],
53+
args = ["$(location :tag-arm64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
54+
)
55+
56+
checkstyle_test(
57+
name = "checkstyle",
58+
include = glob(["*"]),
59+
exclude = glob(["*.md", "VERSION"]),
60+
license_type = "mpl-header",
61+
size = "small",
62+
)

images/docker/ubuntu/Dockerfile renamed to images/docker/ubuntu-2x/Dockerfile.amd64

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55

6-
FROM ubuntu:focal-20210723
6+
FROM ubuntu@sha256:1e48201ccc2ab83afc435394b3bf70af0fa0055215c1e26a5da9b50a1ae367c9
77
RUN apt-get -y update && apt-get install -y openjdk-11-jre-headless && rm -rf /var/lib/apt/lists
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#!/usr/bin/env bash
21
# This Source Code Form is subject to the terms of the Mozilla Public
32
# License, v. 2.0. If a copy of the MPL was not distributed with this
43
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
54

65

7-
echo "$(git -C $BUILD_WORKSPACE_DIRECTORY rev-parse HEAD)"
6+
FROM ubuntu@sha256:c0dd38485ed8b6e149d2fc935d1c61a3b750cda3b3eace0ad6df4abe33fa2b90
7+
RUN apt-get -y update && apt-get install -y openjdk-11-jre-headless && rm -rf /var/lib/apt/lists

images/docker/ubuntu-2x/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# TypeDB Ubuntu 2.x Images
2+
3+
These images are prepared for TypeDB 2.x and contain all the required dependencies like JVM.
4+
5+
Images are prepared for two base architectures: `arm64` and `amd64`. Images are tagged based on the current `VERSION` and Git commit SHA.
6+
7+
## Usage
8+
9+
### Setup
10+
11+
Images are assembled and deployed from local machines with [Docker](https://www.docker.com/get-started/).
12+
13+
To authenticate before starting the work, use:
14+
15+
```shell
16+
docker login
17+
```
18+
19+
### Execution
20+
21+
Using a suitable OS and architecture, use `bazel run //images/docker/ubuntu-2x:<target>`.
22+
23+
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
24+
passed arguments examples.

images/docker/ubuntu-2x/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.29.0

images/docker/ubuntu-3x/BUILD

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
load("//tool/checkstyle:rules.bzl", "checkstyle_test")
5+
6+
# Same repository as 2.x images.
7+
load("//images/docker/ubuntu-2x:deployment.bzl", deployment_docker = "deployment")
8+
9+
# Gen-rules to generate <VERSION>-<PLATFORM> as tag
10+
genrule(
11+
name = "tag-amd64",
12+
srcs = [":VERSION"],
13+
outs = ["tag-amd64.txt"],
14+
cmd = "cat $(location :VERSION) | tr -d '\n' > $(location tag-amd64.txt) && echo \"-amd64\" >> $(location tag-amd64.txt)",
15+
)
16+
17+
genrule(
18+
name = "tag-arm64",
19+
srcs = [":VERSION"],
20+
outs = ["tag-arm64.txt"],
21+
cmd = "cat $(location :VERSION) | tr -d '\n' > $(location tag-arm64.txt) && echo \"-arm64\" >> $(location tag-arm64.txt)",
22+
)
23+
24+
sh_binary(
25+
name = "assemble-docker-amd64",
26+
srcs = ["//images/docker:assemble-docker.sh"],
27+
data = ["Dockerfile.amd64", "VERSION", "tag-amd64"],
28+
deps = [],
29+
args = ["$(location Dockerfile.amd64)", "amd64", "$(location :tag-amd64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
30+
)
31+
32+
sh_binary(
33+
name = "assemble-docker-arm64",
34+
srcs = ["//images/docker:assemble-docker.sh"],
35+
data = ["Dockerfile.arm64", "VERSION", "tag-arm64"],
36+
deps = [],
37+
args = ["$(location Dockerfile.arm64)", "arm64", "$(location :tag-arm64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
38+
)
39+
40+
sh_binary(
41+
name = "deploy-docker-amd64",
42+
deps = [],
43+
srcs = ["//images/docker:deploy-docker.sh"],
44+
data = ["VERSION", "tag-amd64"],
45+
args = ["$(location :tag-amd64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
46+
)
47+
48+
sh_binary(
49+
name = "deploy-docker-arm64",
50+
deps = [],
51+
srcs = ["//images/docker:deploy-docker.sh"],
52+
data = ["VERSION", "tag-arm64"],
53+
args = ["$(location :tag-arm64)", deployment_docker["docker.organisation"], deployment_docker["docker.repository"]]
54+
)
55+
56+
checkstyle_test(
57+
name = "checkstyle",
58+
include = glob(["*"]),
59+
exclude = glob(["*.md", "VERSION"]),
60+
license_type = "mpl-header",
61+
size = "small",
62+
)
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
#!/usr/bin/env bash
21
# This Source Code Form is subject to the terms of the Mozilla Public
32
# License, v. 2.0. If a copy of the MPL was not distributed with this
43
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
54

6-
7-
set -ex
8-
9-
DOCKER_VERSION_LIB=$2
10-
DOCKER_VERSION=`$DOCKER_VERSION_LIB`
11-
DOCKER_ORG=$3
12-
DOCKER_REPO=$4
13-
14-
docker build -f $1 -t $DOCKER_ORG/$DOCKER_REPO:$DOCKER_VERSION .
5+
FROM ubuntu@sha256:3d1556a8a18cf5307b121e0a98e93f1ddf1f3f8e092f1fddfd941254785b95d7
6+
RUN apt-get -y update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
FROM ubuntu@sha256:7c75ab2b0567edbb9d4834a2c51e462ebd709740d1f2c40bcd23c56e974fe2a8
6+
RUN apt-get -y update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists

images/docker/ubuntu-3x/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# TypeDB Ubuntu 3.x Images
2+
3+
These images are prepared for TypeDB 3.x and contain a default SSL configuration.
4+
5+
Images are prepared for two base architectures: `arm64` and `amd64`. Images are tagged based on the current `VERSION` and Git commit SHA.
6+
7+
## Usage
8+
9+
### Setup
10+
11+
Images are assembled and deployed from local machines with [Docker](https://www.docker.com/get-started/).
12+
13+
To authenticate before starting the work, use:
14+
15+
```shell
16+
docker login
17+
```
18+
19+
### Execution
20+
21+
Using a suitable OS and architecture, use `bazel run //images/docker/ubuntu-3x:<target>`.
22+
23+
If Bazel rules do not work on your machine, run `assemble-docker.sh` and `deploy-docker.sh` manually, providing all the required arguments, or `assemble-deploy-all.sh` for a fast update for all versions. See `BUILD` for
24+
passed arguments examples.
25+
26+
#### Separate steps
27+
28+
Use `assemble-docker.sh` and `deploy-docker.sh` separately if needed. See comments and `assemble-deploy-all.sh` for
29+
usage examples.

images/docker/ubuntu-3x/VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
# This Source Code Form is subject to the terms of the Mozilla Public
3+
# License, v. 2.0. If a copy of the MPL was not distributed with this
4+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
6+
set -ex
7+
8+
# Usage: ./assemble-deploy-all.sh
9+
10+
VERSION_FILE="./VERSION"
11+
12+
if [[ ! -f "${VERSION_FILE}" ]]; then
13+
echo "VERSION file not found"
14+
exit 1
15+
fi
16+
17+
VERSION=$(<"$VERSION_FILE")
18+
VERSION=$(echo "$VERSION" | tr -d '[:space:]')
19+
20+
if [[ -z "$VERSION" ]]; then
21+
echo "VERSION file is invalid"
22+
exit 1
23+
fi
24+
25+
echo "Preparing images for version ${VERSION}"
26+
27+
DOCKER_ORG=typedb
28+
DOCKER_REPO=ubuntu
29+
PLATFORMS=("amd64" "arm64") # Update `docker manifest` commands below if it's changed
30+
31+
for ARCH in "${PLATFORMS[@]}"; do
32+
ASSEMBLE_TARGET="//images/docker/ubuntu-3x:assemble-docker-${ARCH}"
33+
DEPLOY_TARGET="//images/docker/ubuntu-3x:deploy-docker-${ARCH}"
34+
bazel run $ASSEMBLE_TARGET
35+
bazel run $DEPLOY_TARGET
36+
done
37+
38+
TAG="${DOCKER_ORG}/${DOCKER_REPO}:${VERSION}"
39+
echo "Creating ${TAG} multi-arch manifest"
40+
docker manifest create "${TAG}" \
41+
--amend "${TAG}-amd64" \
42+
--amend "${TAG}-arm64"
43+
docker manifest push "${TAG}"
44+
45+
echo "Success"

images/docker/ubuntu/BUILD

-34
This file was deleted.

0 commit comments

Comments
 (0)