-
Notifications
You must be signed in to change notification settings - Fork 113
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
Remove Bazel dependency for serialiser and docker images #1214
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple random quick comments
|
||
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
readonly MODULES_DIR="${DIR}/../../target/wasm32-unknown-unknown/release" | ||
readonly OUT_DIR="${DIR}/../bin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we settling on bin
as the output directory? Why not... out
? No need to change it anyways, we'll see later on.
cc @ipetr0v
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the name bin better, as it is a place where we dump binary artefacts. Out seems... strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an out directory for oak_loader
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is for the examples. I don't think the oak_loader
should be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have it as oak/server/bin/oak_loader
at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to @tiziano88 suggestion
@@ -0,0 +1,11 @@ | |||
#!/usr/bin/env bash | |||
|
|||
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea what's going on here, is it trying to resolve its own location?
Could it be a function defined in scripts/common
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can... but this is a bit different. As we source this, I wanted to get the folder of the script, not of the location where this is called. the method we use in most of the scripts works, as we mostly call them directly, not via source
. I think it's a somehow unique usecase. As the comment below, I wouldn't spend too much time on this, as I do think we should remove these files soon and replace them with .toml
s
@@ -0,0 +1,11 @@ | |||
#!/usr/bin/env bash | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also source scripts/common
here, or is it too complicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but app_config_serializer
is the only thing that changes in #1219.
Examples are still compiled from scripts/build_example
@@ -35,6 +35,9 @@ | |||
# Ignore downloaded temporary files, such as the trusted root CA certificates. | |||
/downloads/ | |||
|
|||
# Ignore generated binary example files | |||
**/examples/**/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this directory used to store Wasm files and serialized application configs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just pick a directory name (bin
is fine, out
was also suggested) and use it to generate everything everywhere (not just examples) (including binaries, wasm modules, additional stuff), rather than trying to get things out from target/wasm32-unknown-unknown
and similar.
For cargo build
, there is an --out-dir
flag that should do that already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pointing out that I believe --out-dir is still experimental
FROM oak_docker:latest | ||
|
||
# This runs in the context of each example, so we just copy the bin | ||
COPY bin/config.bin . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which example does it copy?
Or it is being run sequentially for every example?
Is bin/config.bin
rewritten every time a new example is built?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docker has a "context" in which is ran. You can think of it as the "parent folder". For each example image, I use the folder examples/EXAMPLE_NAME as the context, so bin/config.bin is the file for that e.g. examples/hello_world/bin/config.bin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does read a bit weird though. I wonder whether having an explicit ARG config_file
which is passed as docker build --build-arg=config_file=...
would be more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does read a bit weird mean? This is how the Dockerfiles work... maybe the comment should be different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The weirdness I was referring to is that usually a Docker image is built from a known location, but here you are expecting to move it around and be able to rebuild it in other folders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are building an image of an example, so it kind make sense.. but I do see where you are coming from.
|
||
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
readonly MODULES_DIR="${DIR}/../../target/wasm32-unknown-unknown/release" | ||
readonly OUT_DIR="${DIR}/../bin" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an out directory for oak_loader
?
readonly OUT_DIR="${DIR}/../bin" | ||
mkdir --parents "${OUT_DIR}" | ||
|
||
bazel run //oak/common:app_config_serializer -- \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this PR doesn't remove Bazel for building examples.
Why was it moved to build.sh
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's about the linked issue, which is removing Bazel from the invocation of the app_serializer. It is described in the first comment, but not reflected in the title, so I will change that. I think we will always build examples with Bazel (c++ ones), we don't have a goal to remove that.
@@ -0,0 +1,11 @@ | |||
#!/usr/bin/env bash | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but app_config_serializer
is the only thing that changes in #1219.
Examples are still compiled from scripts/build_example
@@ -8,6 +8,7 @@ bazel_build_flags+=( | |||
'--experimental_action_listener=@io_kythe//kythe/cxx/tools/generate_compile_commands:extract_json' | |||
'--noshow_progress' | |||
'--noshow_loading_progress' | |||
'--experimental_extra_action_top_level_only' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang_tidy was not working, not really related to the PR. I am still not 100% sure why, but the "hack-ish" experimental code was trying to compile all bazel targets and getting into some GO code that it didn't configure well. This keeps it to only the first level of targets, which is exactly what we need.
scripts/build_example
Outdated
# Build the base server. | ||
docker build -t oak_docker -f ./oak/server/Dockerfile ./oak/server | ||
# Build and save the example | ||
docker build -t "${EXAMPLE}_image" -f ./examples/Dockerfile "./examples/${EXAMPLE}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the _image
suffix? All docker images are... images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just reusing the existing names. Happy to change it, but I think we use it in a lot of places. cc: @ipetr0v - any reason for using _image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's an example that is being loaded by Oak server inside Docker, it also could be "${EXAMPLE}_server"
.
But just "${EXAMPLE}"
is also fine.
scripts/build_example
Outdated
docker build -t oak_docker -f ./oak/server/Dockerfile ./oak/server | ||
# Build and save the example | ||
docker build -t "${EXAMPLE}_image" -f ./examples/Dockerfile "./examples/${EXAMPLE}" | ||
docker save "${EXAMPLE}_image" > "./examples/${EXAMPLE}/bin/${EXAMPLE}_image.tar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this step for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We first build the server image, on top of that we put the "application" and we save it so we can later "push it". I am not really sure we need the .tar step, but @ipetr0v almost convinced me in a slack chat :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually quite interesting. We could, potentially, have 1 single image, but the issue is that the Docker context would need to be the first common parent directory of the example and server, which is oak top-most directory. And because we have a .dockerignore there for the "overall" image, that conflicts with this. So this is why I made it a two step image. It's also nicer, since we can ideally build the server image once and add to it for each example
Reproducibility Index:
Reproducibility Index diff: |
Fixes #1058. I think this is the first step towards replacing the whole serialiser with a Rust version. I also want to make it a bit more self contained, but that is for the next version.
Checklist
Cloudbuild
cover any TODOs and/or unfinished work.
construction.