Add Dockerfile & cleanup

This commit is contained in:
daijro 2024-07-26 14:03:46 -05:00
parent 89cba6aebb
commit 5b6de88f97
8 changed files with 86 additions and 18 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
* text=auto eol=lf

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM python:3.11-slim-bullseye
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install necessary packages
RUN apt-get update && apt-get install -y \
# Makefile utils
build-essential make git msitools wget unzip \
# Camoufox build system utils
p7zip-full golang-go
RUN make fetch && make mozbootstrap
ENTRYPOINT ["python3", "./multibuild.py"]

View file

@ -4,16 +4,17 @@ export
ff_source_dir := firefox-$(version) ff_source_dir := firefox-$(version)
lw_source_dir := camoufox-$(version)-$(release) lw_source_dir := camoufox-$(version)-$(release)
debs := python3 python3-dev python3-pip p7zip-full golang-go debs := python3 python3-dev python3-pip p7zip-full golang-go msitools wget
rpms := python3 python3-devel p7zip golang rpms := python3 python3-devel p7zip golang msitools wget
pacman := python python-pip p7zip go pacman := python python-pip p7zip go msitools wget
.PHONY: help fetch clean distclean build package build-launcher check-arch edits run bootstrap dir package-common package-linux package-macos package-windows .PHONY: help fetch clean distclean build package build-launcher check-arch edits run bootstrap mozbootstrap dir package-common package-linux package-macos package-windows
help: help:
@echo "Available targets:" @echo "Available targets:"
@echo " fetch - Clone Firefox source code" @echo " fetch - Clone Firefox source code"
@echo " bootstrap - Set up build environment" @echo " bootstrap - Set up build environment"
@echo " mozbootstrap - Sets up mach"
@echo " dir - Prepare Camoufox source directory" @echo " dir - Prepare Camoufox source directory"
@echo " edits - Camoufox developer UI" @echo " edits - Camoufox developer UI"
@echo " build-launcher - Build launcher" @echo " build-launcher - Build launcher"
@ -37,9 +38,12 @@ dir:
cp -r $(ff_source_dir) $(lw_source_dir) cp -r $(ff_source_dir) $(lw_source_dir)
python3 scripts/patch.py $(version) $(release) python3 scripts/patch.py $(version) $(release)
mozbootstrap:
cd $(ff_source_dir) && MOZBUILD_STATE_PATH=$$HOME/.mozbuild ./mach --no-interactive bootstrap --application-choice=browser
bootstrap: dir bootstrap: dir
(sudo apt-get -y install $(debs) || sudo dnf -y install $(rpms) || sudo pacman -Sy $(pacman)) (sudo apt-get -y install $(debs) || sudo dnf -y install $(rpms) || sudo pacman -Sy $(pacman))
cd $(lw_source_dir) && MOZBUILD_STATE_PATH=$$HOME/.mozbuild ./mach --no-interactive bootstrap --application-choice=browser make mozbootstrap
clean: clean:
rm -rf $(lw_source_dir) rm -rf $(lw_source_dir)

View file

@ -2,10 +2,10 @@
<h1 align="center">Camoufox</h1> <h1 align="center">Camoufox</h1>
<h4 align="center">A stealthy, minimalistic Firefox fork for web scraping 🦊</h4> <h4 align="center">A stealthy, minimalistic, custom build of Firefox for web scraping 🦊</h4>
<p align="center"> <p align="center">
Camoufox aims to be a minimalistic browser that for robust fingerprint injection & anti-bot evasion. Camoufox aims to be a minimalistic browser for robust fingerprint injection & anti-bot evasion.
</p> </p>
@ -22,6 +22,7 @@ Camoufox aims to be a minimalistic browser that for robust fingerprint injection
- Full integration of Playwright's Juggler ✅ - Full integration of Playwright's Juggler ✅
- Patches from LibreWolf & Ghostery to remove Mozilla services ✅ - Patches from LibreWolf & Ghostery to remove Mozilla services ✅
- Optimized for memory and speed ✅ - Optimized for memory and speed ✅
- Stays up to date with the latest Firefox version ⌚
#### What's planned? #### What's planned?
@ -295,7 +296,9 @@ graph TD
end end
``` ```
### Build CLI This was originally forked from the LibreWolf build system.
## Build CLI
> [!WARNING] > [!WARNING]
> Camoufox's build system is designed to be used in Linux. WSL will not work! > Camoufox's build system is designed to be used in Linux. WSL will not work!
@ -329,6 +332,49 @@ make package-windows arch=x86
make package-macos arch=amd64 make package-macos arch=amd64
``` ```
### Using Docker
Camoufox can be built through Docker on all platforms.
1. Create the Docker image containing Firefox's source code:
```bash
docker build -t camoufox-builder .
```
2. Build Camoufox patches to a target platform and architecture:
```bash
docker run camoufox-builder --target <os> --arch <arch>
# Asset files will be printed at the end
```
3. Download zip file assets:
```bash
docker ps # Find container ID
docker cp <container id>:/app/<asset>.zip .
```
<details>
<summary>
CLI Parameters
</summary>
```bash
options:
-h, --help show this help message and exit
--target {linux,windows,macos}
Target platform for the build
--arch {x86_64,arm64,i686}
Target architecture for the build
```
</details>
---
## Development Notes ## Development Notes
### How to make a patch ### How to make a patch

Binary file not shown.

View file

@ -49,7 +49,7 @@ class BSYS:
return glob.glob(package_pattern) return glob.glob(package_pattern)
def clean(self): def clean(self):
exec('make veryclean') exec('make clean')
def main(): def main():
@ -62,7 +62,7 @@ def main():
) )
parser.add_argument("--bootstrap", action="store_true", help="Bootstrap the build system") parser.add_argument("--bootstrap", action="store_true", help="Bootstrap the build system")
parser.add_argument( parser.add_argument(
"--no-clean", action="store_true", help="Do not clean the build directory before starting" "--clean", action="store_true", help="Clean the build directory before starting"
) )
args = parser.parse_args() args = parser.parse_args()
@ -72,7 +72,7 @@ def main():
if args.bootstrap: if args.bootstrap:
builder.bootstrap() builder.bootstrap()
# Clean if requested # Clean if requested
if not args.no_clean: if args.clean:
builder.clean() builder.clean()
# Run build # Run build
builder.build() builder.build()

View file

@ -1,7 +1,7 @@
#!/usr/bin/bash #!/usr/bin/bash
if [ ! -f browser/locales/shipped-locales ]; then if [ ! -f browser/locales/shipped-locales ]; then
echo "ERROR: Run this script from the root of the LibreWolf source code" echo "ERROR: Run this script from the root of the Camoufox source code"
exit 1 exit 1
fi fi
@ -26,14 +26,14 @@ generate_locale() {
echo_status "Downloading locale \"$1\"" echo_status "Downloading locale \"$1\""
wget -q -O browser/locales/l10n/$1.zip https://hg.mozilla.org/l10n-central/$1/archive/tip.zip wget -q -O browser/locales/l10n/$1.zip https://hg.mozilla.org/l10n-central/$1/archive/tip.zip
echo_status "Extracting locale \"$1\"" echo_status "Extracting locale \"$1\""
unzip -qo browser/locales/l10n/$1.zip -d browser/locales/l10n/ 7z x -y -obrowser/locales/l10n browser/locales/l10n/$1.zip > /dev/null
mv browser/locales/l10n/$1-*/ browser/locales/l10n/$1/ mv browser/locales/l10n/$1-*/ browser/locales/l10n/$1/
rm -f browser/locales/l10n/$1.zip rm -f browser/locales/l10n/$1.zip
echo_status "Generating locale \"$1\"" echo_status "Generating locale \"$1\""
mv browser/locales/l10n/$1/browser/branding/official browser/locales/l10n/$1/browser/branding/librewolf mv browser/locales/l10n/$1/browser/branding/official browser/locales/l10n/$1/browser/branding/camoufox
find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla Firefox/LibreWolf/g' {} \; find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla Firefox/Camoufox/g' {} \;
find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla/LibreWolf/g' {} \; find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Mozilla/Camoufox/g' {} \;
find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Firefox/LibreWolf/g' {} \; find browser/locales/l10n/$1 -type f -exec sed -i -e 's/Firefox/Camoufox/g' {} \;
echo_status "Done" echo_status "Done"
sleep 0.3 sleep 0.3
echo_status echo_status