Skip to content

Commit

Permalink
feat (cli): Introduce Enola container image for end-users (re. enola-…
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Dec 31, 2023
1 parent baa1fa9 commit 9c47bc6
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ indent_size = unset
tab_width = unset

# The ./enola* files are Bash scripts (without *.bash extension)
[enola]
indent_size = 2
tab_width = 2
[enola-dl]
[enola*]
indent_size = 2
tab_width = 2

Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM gcr.io/distroless/java21-debian12:nonroot

# Loosely inspired by https://github.com/GoogleContainerTools/distroless/blob/main/examples/java/Dockerfile

# For consistency, use Enola's standard "distro"
# (instead of e.g. directly COPY bazel-bin/cli/enola_deploy.jar)...

# ...BUT note that we still CANNOT just do e.g. ENTRYPOINT ["enola"],
# because in a (non :debug!) distroless we (intentionally!) do not
# even have any shell - so we still just have to "java -jar enola".

# Nota bene: The /app/CWD/ and ../enola circus is to be able to use
# 'docker run ... -v "$PWD":/app/CWD/:Z' in the 'enola-c' launch script;
# see docs/use/index.md.

WORKDIR /app/CWD/
COPY --chmod=0777 --chown=nonroot:nonroot site/download/latest/enola /app/enola
ENTRYPOINT [ "java", "-jar", "../enola" ]

# To debug, replace FROM :nonroot with :debug-nonroot,
# and use ENTRYPOINT [ "/busybox/sh" ] instead of above,
# and then "docker run" WITHOUT any additional arguments.
22 changes: 22 additions & 0 deletions docs/download/latest/enolac
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2023 The Enola <https://enola.dev> Authors
#
# 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
#
# https://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 -euo pipefail
: "${ENOLA_IMAGE:=ghcr.io/enola-dev/enola:latest}"

set -x
docker run --rm -v "$PWD":/app/CWD/:Z -it "$ENOLA_IMAGE" "$@"
12 changes: 12 additions & 0 deletions docs/use/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ once a day or so.
Of course, whether you are comfortable with such _"Continuous Delivery",_ and thus
_"always living at `HEAD`",_ like in _"rolling release distros",_ or have any concerns
with such an approach e.g. from a security perspective, is entirely your choice - YMMV.

## Container

[`enolac`](../download/latest/enolac) runs Enola from a Container, on Docker (or Podman,
or CRI-O; locally or e.g. on Kubernetes).

It takes the exact same CLI arguments as the "regular" `enola` binary, but pulls it
via a container image, instead of a "local installation", as above.

It appropriately "mounts" the current working directory into the container, so that
relative `file:` URIs should work. Absolute paths on your host won't work, because they
are not accessible to the container ("by design").
3 changes: 3 additions & 0 deletions test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ echo
echo $ b build //...
bazelisk build //...

# Test distros: 1. End-user distributed fat über JAR, 2. Container Image
tools/distro/test.bash

# Check if https://pre-commit.com is available (and try to install it not)
if ! [ -e "./.venv/bin/pre-commit" ]; then
echo "https://pre-commit.com is not available..."
Expand Down
32 changes: 32 additions & 0 deletions tools/distro/test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
#
# Copyright 2023 The Enola <https://enola.dev> Authors
#
# 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
#
# https://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.

# TODO Transform this into a Bazel target instead...
set -euox pipefail

tools/distro/build.bash

# TODO Test output
site/download/latest/enola help
site/download/latest/enola --version
site/download/latest/enola get --model file:docs/use/library/model.yaml demo.book_kind/0-13-140731-7

# TODO Test output
ENOLA_IMAGE=localhost/enola:latest docs/download/latest/enolac help
ENOLA_IMAGE=localhost/enola:latest docs/download/latest/enolac --version
ENOLA_IMAGE=localhost/enola:latest docs/download/latest/enolac \
get --model file:docs/use/library/model.yaml demo.book_kind/0-13-140731-7

0 comments on commit 9c47bc6

Please sign in to comment.