Skip to content
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

Move away from $OFRAK_DIR argument to $PACKAGE_PATH for Docker builds #425

Merged
merged 1 commit into from
Feb 23, 2024
Merged
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
8 changes: 7 additions & 1 deletion build_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def create_dockerfile_base(config: OfrakImageConfig) -> str:
continue
with open(dockerstage_path) as file_handle:
dockerstub = file_handle.read()
# Cannot use ENV here because of multi-stage build FROM, so replace direclty in Docerkstage contents
dockerstub = dockerstub.replace("$PACKAGE_DIR", package_path)
dockerfile_base_parts += [f"### {dockerstage_path}", dockerstub]

dockerfile_base_parts += [
Expand All @@ -207,7 +209,11 @@ def create_dockerfile_base(config: OfrakImageConfig) -> str:
dockerstub_path = os.path.join(package_path, "Dockerstub")
with open(dockerstub_path) as file_handle:
dockerstub = file_handle.read()
dockerfile_base_parts += [f"### {dockerstub_path}", dockerstub]
dockerfile_base_parts += [
f"### {dockerstub_path}",
f"ENV PACKAGE_PATH={package_path}",
dockerstub,
]
# Collect python dependencies
python_reqs = []
for suff in requirement_suffixes:
Expand Down
5 changes: 2 additions & 3 deletions disassemblers/ofrak_binary_ninja/Dockerstub
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
RUN apt-get update && apt-get install -y libdbus-1-3
ARG OFRAK_DIR=.
COPY $OFRAK_DIR/disassemblers/ofrak_binary_ninja/install_binary_ninja_headless_linux.sh /tmp/
COPY $OFRAK_DIR/disassemblers/ofrak_binary_ninja/pin_version.py /tmp/
COPY $PACKAGE_PATH/install_binary_ninja_headless_linux.sh /tmp/
COPY $PACKAGE_PATH/pin_version.py /tmp/
RUN --mount=type=secret,id=serial --mount=type=secret,id=license.dat,dst=/root/.binaryninja/license.dat /tmp/install_binary_ninja_headless_linux.sh && \
python3 /tmp/pin_version.py "3.2.3814 Headless" && \
rm /tmp/install_binary_ninja_headless_linux.sh && \
Expand Down
3 changes: 1 addition & 2 deletions disassemblers/ofrak_ghidra/Dockerstub
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ RUN mkdir -p /opt/rbs && \
rm -f ghidra_10.1.2_PUBLIC_20220125.zip && \
mv ghidra_10.1.2_PUBLIC/ /opt/rbs/ghidra_10.1.2_PUBLIC

ARG OFRAK_DIR=.
WORKDIR /
COPY $OFRAK_DIR/disassemblers/ofrak_ghidra/server.conf /opt/rbs/ghidra_10.1.2_PUBLIC/server/
COPY $PACKAGE_PATH/server.conf /opt/rbs/ghidra_10.1.2_PUBLIC/server/
3 changes: 1 addition & 2 deletions frontend/Dockerstage
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM node:latest AS svelte

ARG OFRAK_DIR=.
COPY --chown=node:node $OFRAK_DIR/frontend /home/node/frontend
COPY --chown=node:node $PACKAGE_DIR /home/node/frontend

WORKDIR /home/node/frontend
RUN su node -c "npm install && npm run build"
9 changes: 4 additions & 5 deletions frontend/Dockerstub
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ RUN apt-get update && apt-get install --yes nginx

COPY --from=svelte --chown=root:root /home/node/frontend/dist /ofrak_gui

ARG OFRAK_DIR=.
COPY $OFRAK_DIR/frontend/nginx.conf /etc/nginx/sites-enabled/default
COPY $PACKAGE_PATH/nginx.conf /etc/nginx/sites-enabled/default

COPY $OFRAK_DIR/mkdocs.yml /mkdocs.yml
COPY $OFRAK_DIR/docs /docs
COPY $OFRAK_DIR/examples /examples
COPY $PACKAGE_PATH/../mkdocs.yml /mkdocs.yml
COPY $PACKAGE_PATH/../docs /docs
COPY $PACKAGE_PATH/../examples /examples
whyitfor marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions ofrak_core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Changed
- Change `FreeSpaceModifier` & `PartialFreeSpaceModifier` behavior: an optional stub that isn't free space can be provided and fill-bytes for free space can be specified. ([#409](https://github.com/redballoonsecurity/ofrak/pull/409))
- `Resource.flush_to_disk` method renamed to `Resource.flush_data_to_disk`. ([#373](https://github.com/redballoonsecurity/ofrak/pull/373))
- `build_image.py` supports building Docker images with OFRAK packages from any ancestor directory. ([#425](https://github.com/redballoonsecurity/ofrak/pull/425))

## [3.2.0](https://github.com/redballoonsecurity/ofrak/compare/ofrak-v3.1.0...ofrak-v3.2.0)
### Added
Expand Down
7 changes: 3 additions & 4 deletions ofrak_tutorial/Dockerstub
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG OFRAK_DIR=.
COPY $OFRAK_DIR/mkdocs.yml /mkdocs.yml
COPY $OFRAK_DIR/docs /docs
COPY $OFRAK_DIR/examples /examples
COPY $PACKAGE_PATH/../mkdocs.yml /mkdocs.yml
COPY $PACKAGE_PATH/../docs /docs
COPY $PACKAGE_PATH/../examples /examples
Loading