Skip to content

Commit f1d64a3

Browse files
arman-bdclaude
andcommitted
feat: Add Docker testing environment and fix build issues
Build fixes: - Compile nghttp2 with -fPIC flag for shared library compatibility - Add POSIX feature macros to browser_profiles.c - Include strings.h for strcasecmp function - Fix ja3_hash to use MD5 hash instead of full JA3 string (33 chars max) Docker testing: - Add Dockerfile.test that mimics GitHub Actions ubuntu-latest - Add docker-compose.test.yml for easier Docker management - Add Makefile targets: docker-build, docker-test, docker-shell - Add .dockerignore to optimize build context This allows local testing in the exact CI environment before pushing, significantly reducing CI iteration time. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 055fe5b commit f1d64a3

File tree

6 files changed

+148
-3
lines changed

6 files changed

+148
-3
lines changed

.dockerignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual environments
24+
venv/
25+
ENV/
26+
env/
27+
.venv
28+
29+
# IDE
30+
.vscode/
31+
.idea/
32+
*.swp
33+
*.swo
34+
*~
35+
36+
# Testing
37+
.pytest_cache/
38+
.coverage
39+
htmlcov/
40+
.tox/
41+
42+
# OS
43+
.DS_Store
44+
Thumbs.db
45+
46+
# Git
47+
.git/
48+
.gitignore
49+
.gitattributes
50+
51+
# CI
52+
.github/
53+
54+
# Documentation
55+
docs/_build/
56+
*.md
57+
58+
# Local development
59+
.uv/
60+
uv.lock

Dockerfile.test

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Test Dockerfile for httpmorph CI environment
2+
# Mimics GitHub Actions ubuntu-latest environment
3+
4+
FROM ubuntu:22.04
5+
6+
# Prevent interactive prompts during package installation
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
# Install system dependencies (matching CI workflow)
10+
RUN apt-get update && apt-get install -y \
11+
cmake \
12+
ninja-build \
13+
libssl-dev \
14+
pkg-config \
15+
autoconf \
16+
automake \
17+
libtool \
18+
git \
19+
curl \
20+
build-essential \
21+
python3.11 \
22+
python3.11-dev \
23+
python3-pip \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
# Set Python 3.11 as default
27+
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1
28+
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1
29+
30+
# Upgrade pip
31+
RUN python3 -m pip install --upgrade pip setuptools wheel
32+
33+
# Set working directory
34+
WORKDIR /workspace
35+
36+
# Copy project files
37+
COPY . .
38+
39+
# Setup vendor dependencies
40+
RUN chmod +x scripts/setup_vendors.sh && ./scripts/setup_vendors.sh
41+
42+
# Install Python package in development mode
43+
RUN pip install -e ".[dev]"
44+
45+
# Default command: run tests
46+
CMD ["pytest", "tests/", "-v"]

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help setup build install test clean benchmark docs lint format sync
1+
.PHONY: help setup build install test clean benchmark docs lint format sync docker-build docker-test docker-shell
22

33
help:
44
@echo "httpmorph - Development commands"
@@ -15,6 +15,11 @@ help:
1515
@echo " make lint - Run linters (ruff, mypy)"
1616
@echo " make format - Format code (ruff)"
1717
@echo ""
18+
@echo "Docker (CI Testing):"
19+
@echo " make docker-build - Build Docker test container (mimics CI)"
20+
@echo " make docker-test - Run tests in Docker"
21+
@echo " make docker-shell - Open shell in Docker for debugging"
22+
@echo ""
1823
@echo "Cleanup:"
1924
@echo " make clean - Remove build artifacts"
2025
@echo " make clean-all - Remove build artifacts and vendor dependencies"
@@ -81,3 +86,16 @@ rebuild: clean setup build
8186
# Check if everything is working
8287
check: lint test
8388
@echo "All checks passed!"
89+
90+
# Docker targets for CI testing
91+
docker-build:
92+
@echo "Building Docker test container (mimics GitHub Actions)..."
93+
docker build -f Dockerfile.test -t httpmorph-test .
94+
95+
docker-test: docker-build
96+
@echo "Running tests in Docker container..."
97+
docker run --rm httpmorph-test pytest tests/ -v
98+
99+
docker-shell:
100+
@echo "Opening shell in Docker container for debugging..."
101+
docker run --rm -it -v $(PWD):/workspace httpmorph-test bash

docker-compose.test.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3.8'
2+
3+
services:
4+
test:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.test
8+
volumes:
9+
- .:/workspace
10+
- vendor-cache:/workspace/vendor
11+
environment:
12+
- PYTHONDONTWRITEBYTECODE=1
13+
- PYTHONUNBUFFERED=1
14+
command: bash
15+
16+
volumes:
17+
vendor-cache:

scripts/setup_vendors.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ cd nghttp2
125125
if [ ! -f "lib/.libs/libnghttp2.a" ]; then
126126
echo "Building nghttp2..."
127127

128-
./configure --prefix="$VENDOR_DIR/nghttp2/install" \
128+
# Build with -fPIC for use in shared libraries
129+
CFLAGS="-fPIC" ./configure --prefix="$VENDOR_DIR/nghttp2/install" \
129130
--enable-lib-only \
130131
--enable-static \
131132
--disable-shared \

src/tls/browser_profiles.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
* browser_profiles.c - Browser TLS/HTTP fingerprint profiles implementation
33
*/
44

5+
#define _POSIX_C_SOURCE 200809L
6+
57
#include "browser_profiles.h"
68
#include <stdlib.h>
79
#include <string.h>
10+
#include <strings.h> /* for strcasecmp */
811
#include <time.h>
912

1013
/* Chrome 131 Profile */
@@ -86,7 +89,7 @@ const browser_profile_t PROFILE_CHROME_131 = {
8689
.window_update = 15663105,
8790
},
8891

89-
.ja3_hash = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
92+
.ja3_hash = "cd08e31494f9531f560d64c695473da9", /* MD5 of JA3 string */
9093
};
9194

9295
/* Chrome 124 Profile (older version) */

0 commit comments

Comments
 (0)