From e899a38690ac2d8dd17784b817f126305f54cda6 Mon Sep 17 00:00:00 2001 From: daijro Date: Wed, 31 Jul 2024 03:52:18 -0500 Subject: [PATCH] Dockerfile: Allow use of local ~/.mozbuild, etc. --- Dockerfile | 23 +++++++++++++++-------- README.md | 47 +++++++++++++++++++++++++++++++---------------- multibuild.py | 5 +++-- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7ca56d2..7ff4140 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,25 @@ FROM ubuntu:latest WORKDIR /app -# Copy the current directory contents into the container at /app +# Copy the current directory into the container at /app COPY . /app # Install necessary packages RUN apt-get update && apt-get install -y \ - # Makefile utils + # Makefile utils build-essential make git msitools wget unzip \ - # Python - python3 python3-dev python3-pip \ - # Camoufox build system utils - p7zip-full golang-go + # Python + python3 python3-dev python3-pip \ + # Camoufox build system utils + p7zip-full golang-go -RUN make fetch && make mozbootstrap +# Fetch Firefox & apply initial patches +RUN make fetch && \ + make mozbootstrap && \ + mkdir /app/dist -ENTRYPOINT ["python3", "./multibuild.py"] +# Mount .mozbuild directory and dist folder +VOLUME /root/.mozbuild +VOLUME /app/dist + +ENTRYPOINT ["python3", "./multibuild.py"] \ No newline at end of file diff --git a/README.md b/README.md index 7ddf5ec..080fbc3 100644 --- a/README.md +++ b/README.md @@ -345,15 +345,7 @@ docker build -t camoufox-builder . 2. Build Camoufox patches to a target platform and architecture: ```bash -docker run camoufox-builder --target --arch -# Asset files will be printed at the end -``` - -3. Download zip file assets: - -```bash -docker ps # Find container ID -docker cp :/app/.zip . +docker run -v "$(pwd)/dist:/app/dist" camoufox-builder --target --arch ```
@@ -362,7 +354,7 @@ CLI Parameters ```bash -options: +Options: -h, --help show this help message and exit --target {linux,windows,macos} Target platform for the build @@ -372,6 +364,27 @@ options:
+
+ +How can I use my local ~/.mozbuild directory? + + +If you want to use the host's .mozbuild directory, you can use the following command instead to run the docker: + +```bash +docker run \ + -v "$HOME/.mozbuild":/root/.mozbuild:rw,z \ + -v "$(pwd)/dist:/app/dist" \ + camoufox-builder \ + --target \ + --arch +``` + +
+ +
+ +Build artifacts will now appear written under the `dist/` folder. --- @@ -393,16 +406,18 @@ To use, select "Reset workspace", make changes in the camoufox-\*/ folder, then ### How to work on an existing patch -In the developer UI, reset your workspace, then select "Select patches" and select all **but** the one you want to edit. - -Then, in the camoufox-\*/ folder, create a new commit: +1. In the developer UI, reset your workspace. +2. Then, click "Select patches", and select all **but** the one you want to edit. +3. Create a checkpoint. This will commit the current workspace to the local repo: ```bash -git commit -m "Base commit" -a +make checkpoint ``` -Then in the developer UI, hit "Select patches" and apply the patch you would like to edit. +4. In the developer UI, click "Select patches", and _apply_ the patch you would like to edit. -After you're done editing, hit "Write workspace to patch", and overwrite the existing patch. + Make your changes. Test builds can be made with `make build` and `make run`. + +5. After you're done editing, hit "Write workspace to patch", and overwrite the existing patch. --- diff --git a/multibuild.py b/multibuild.py index 7b9edc7..e1d63a8 100644 --- a/multibuild.py +++ b/multibuild.py @@ -78,8 +78,9 @@ def main(): builder.build() # Run package builder.package() - # Print assets - print(builder.assets) + # Move assets to dist + for asset in builder.assets: + os.rename(asset, f'dist/{asset}') if __name__ == "__main__":