-
Notifications
You must be signed in to change notification settings - Fork 131
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
Docker image improvements and Makefile targets #563
base: master
Are you sure you want to change the base?
Conversation
…ad section and building as well as expecting a license files to be included
I do not think we should move forward with most of the changes in this pull request.
The only change that might be alright is changing the order of |
Yes. the order in yaml must agree with the dependencies.
We need to finally land #218, then the check would no longer have to be manual. |
@rbs-jacob I can remove the comments and the setup.py related commands but otherwise I think the rest of the changes are worthwhile. The current method for downloading, building, and running ofrak in a container as outlined by the documenta is cumbersome. Moreover there is no easy way to run the tests locally that are ran on the remote (github) without examining the test-all.yml. Which again, in my opinion, is cumbersome. Users shouldn't have to have a deep understanding of the ofrak build system in order to simply build and run it in a container. Take the following two key changes for example: .PHONY: ofrak-%
ofrak-%: ## Build OFRAK image using ofrak-<name>
@echo "Building OFRAK image using config: ofrak-$*.yml"
python3 build_image.py --config ofrak-$*.yml --base --finish
.PHONY: start-ofrak-%
start-ofrak-%: ## Start OFRAK image using ofrak-<name>
make ensure-ofrak-license image_name=$*
@echo "Starting OFRAK image using config: ofrak-$*.yml..."
docker run \
--rm \
--detach \
--hostname ofrak \
--name ofrak-$* \
--interactive \
--tty \
--publish 8877:80 \
--volume $(PWD)/ofrak.license:/ofrak.license \
redballoonsecurity/ofrak/$*:latest I would argue these are barely more complex than the normal commands that the user would execute to build and run ofrak in a container. For example if a user wanted to use the ofrak-dev.yml config file they would either need to edit the existing makefile or run: python3 build_image.py --config ofrak-dev.yml --base --finish
docker run --rm --detach --hostname ofrak --name ofrak-dev --interactive --tty --publish 8877:80 --volume $(PWD)/ofrak.license:/ofrak.license redballoonsecurity/ofrak/dev:latest Theres a fair number of unintuitive arguments for each command as shown by the fact that we have a ~600 word documentation section just to describe the two commands needed to build and run docker. But by adding these to the Makefile we simplify it for the user such they they would only have to run: make ofrak-dev
make start-ofrak-dev Moving patch_maker to the top beginning of the yaml made a big difference in how often that layer's cache becomes invalidated by changes in other layers. Given the time required to download and build this stage (easily ~30 minutes on some systems), this small change makes a big difference. If the order of the yaml matters, we should clearly document it and explore other ways of keeping patch_maker's layer cache from becoming invalid. As for the licensing it requires the user to have generated the ofrak.license file, a step that is automatically invoked if the file is missing when the user runs either of the start commands. This brings up the |
autoflake --in-place --remove-all-unused-imports --ignore-init-module-imports -r . -c | ||
|
||
.PHONY: inspect | ||
inspect: autoflake check-black | ||
inspect: ## Runs autoflake then check-black | ||
autoflake |
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.
This should be $(MAKE) autoflake
, otherwise you are dropping all the arguments
inspect: autoflake check-black | ||
inspect: ## Runs autoflake then check-black | ||
autoflake | ||
make check-black |
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 better to use $(MAKE)
for recursive make calls.
ensure-ofrak-license: | ||
@if [ ! -f "$(license_file)" ]; then \ | ||
echo "No local 'ofrak.license' found."; \ | ||
echo "Launching container to obtain license from IMAGE: 'redballoonsecurity/ofrak/$(image_name):latest'..."; \ | ||
docker run --name ofrak-license-check \ | ||
-it \ | ||
--entrypoint '' \ | ||
redballoonsecurity/ofrak/$(image_name):latest \ | ||
ofrak license; \ | ||
if [ "$$?" -eq 0 ]; then \ | ||
echo "License accepted. Copying license file out of container..."; \ | ||
docker cp ofrak-license-check:/ofrak_core/ofrak/license/license.json "$(license_file)"; \ | ||
else \ | ||
echo "License was NOT accepted or command failed. Exiting..."; \ | ||
docker rm ofrak-license-check >/dev/null 2>&1 || true; \ | ||
exit 1; \ | ||
fi; \ | ||
docker rm ofrak-license-check >/dev/null 2>&1 || true; \ | ||
fi |
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 at the very least somewhere in this process we need to tell the user where to place their commercial license file in.
# make start-ofrak-tutorial -> starts ofrak-tutorial image | ||
.PHONY: start-ofrak-% | ||
start-ofrak-%: ## Start OFRAK image using ofrak-<name> | ||
make ensure-ofrak-license image_name=$* |
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.
Pleas use $(MAKE)
$(call volume_mounts,$(PACKAGES)) --entrypoint bash \ | ||
redballoonsecurity/ofrak/$*:latest \ | ||
-c 'make develop \ | ||
&& ofrak license --community --i-agree \ |
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.
Should not have the automatic ofrak license
step.
--entrypoint bash \ | ||
--volume "$(PWD)":/ofrak \ | ||
redballoonsecurity/ofrak/angr:latest \ | ||
-c "ofrak license --community --i-agree \ |
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.
Should not have an automatic ofrak license
step.
--entrypoint bash \ | ||
redballoonsecurity/ofrak/tutorial:latest \ | ||
-c "python -m ofrak_ghidra.server start \ | ||
&& ofrak license --community --i-agree \ |
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.
Should not have an automatic ofrak license
step.
@@ -21,5 +21,6 @@ extra_build_args: | |||
] | |||
entrypoint: | | |||
nginx \ | |||
& python3 -m ofrak_ghidra.server start \ | |||
& python3 -m ofrak gui -H 0.0.0.0 -p 8877 --backend ghidra | |||
&& ofrak license -l /ofrak.license --i-agree \ |
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.
Should not have an automatic ofrak license
step.
@@ -12,5 +12,6 @@ packages_paths: | |||
] | |||
entrypoint: | | |||
nginx \ | |||
& python3 -m ofrak_ghidra.server start \ | |||
& python3 -m ofrak gui -H 0.0.0.0 -p 8877 --backend ghidra | |||
&& ofrak license -l /ofrak.license --i-agree \ |
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.
Should not have an automatic ofrak license
step.
--allow-root \ | ||
--ip 0.0.0.0 \ | ||
--notebook-dir "/ofrak_tutorial/notebooks" | ||
ofrak license -l ofrak.license --i-agree \ |
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.
Should not have an automatic ofrak license
step.
Authored by @Jepson2k
One sentence summary of this PR (This should go in the CHANGELOG!)
Fix small issues with Docker images and add Makefile targets for creating/starting them.
Link to Related Issue(s)
#547
Please describe the changes in your request.
Anyone you think should look at this, specifically?