-
Notifications
You must be signed in to change notification settings - Fork 30
Dockerize Fastpath #935
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
Merged
LDiazN
merged 29 commits into
master
from
support-deploying-fastpath-as-docker-container
Jun 11, 2025
Merged
Dockerize Fastpath #935
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0d460cf
First steps
hynnot ef14b0a
Next steps
hynnot 5856ed4
Merge branch 'master' into support-deploying-fastpath-as-docker-conta…
LDiazN 9342b85
Use right source for clickhouse image
LDiazN 8863b73
Add requests library used in tests
LDiazN 62a06e4
Add docker related operations
LDiazN 59572bd
Added profiles to select which services to run
LDiazN 78a9dad
Add context comment
LDiazN a592191
Remove dependency on clickhouse to allow fastpath to run standalone
LDiazN dd59865
binding to 0.0.0.0 to accept traffic from outside docker
LDiazN 2d0b94b
Using simpler dockerfile configuration
LDiazN d1827d1
Using simpler dockerfile configuration
LDiazN cc4be7e
Fixing dependency betwen fastpath and clickhouse
LDiazN f696e9e
Improving usability of makefile
LDiazN d9c647e
Creating multi stage docker file
LDiazN 5e78cc4
Remove deprecated pkg_resources dependency
LDiazN 41f7176
Skip broken tests
LDiazN 522a851
Upgrade deprecated upload-artifact action in test_fastpath.yml
LDiazN 2d19f51
Move fastpath.conf to the top dir
LDiazN 74b62e5
Merge branch 'support-deploying-fastpath-as-docker-container' of http…
LDiazN e65dae0
remove useless print
LDiazN 9f9c286
Working on adding integration tests for the docker deployment
LDiazN 894d3e0
Added integration tests with docker
LDiazN 6457384
Added requests to simplify testing
LDiazN 397908e
Add more integration tests
LDiazN c1a1c2d
Add better healthcheck to docker compose
LDiazN 590fab8
Pin docker container version
LDiazN 7d490a4
Remove hardcoded reload config
LDiazN 12fa4e4
Merge branch 'master' into support-deploying-fastpath-as-docker-conta…
LDiazN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Stage 1: Building | ||
FROM python:3.13.3-slim-bookworm AS builder | ||
|
||
RUN apt update && apt install -y --no-install-recommends \ | ||
build-essential \ | ||
gcc \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt . | ||
|
||
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt | ||
|
||
# Stage 2: Running | ||
FROM python:3.13.3-slim-bookworm | ||
|
||
RUN apt update && rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /install /usr/local | ||
COPY . . | ||
|
||
ENV PYTHONPATH=/app | ||
COPY fastpath.conf /etc/ooni/fastpath.conf | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["python", "/app/run_fastpath"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
-- Create tables for Clickhouse integ tests | ||
|
||
-- Main tables | ||
|
||
CREATE TABLE IF NOT EXISTS default.fastpath | ||
( | ||
`measurement_uid` String, | ||
`report_id` String, | ||
`input` String, | ||
`probe_cc` String, | ||
`probe_asn` UInt32, | ||
`test_name` String, | ||
`test_start_time` DateTime, | ||
`measurement_start_time` DateTime, | ||
`filename` String, | ||
`scores` String, | ||
`platform` String, | ||
`anomaly` String, | ||
`confirmed` String, | ||
`msm_failure` String, | ||
`domain` String, | ||
`software_name` String, | ||
`software_version` String, | ||
`control_failure` String, | ||
`blocking_general` Float32, | ||
`is_ssl_expected` Int8, | ||
`page_len` Int32, | ||
`page_len_ratio` Float32, | ||
`server_cc` String, | ||
`server_asn` Int8, | ||
`server_as_name` String, | ||
`update_time` DateTime64(3) MATERIALIZED now64(), | ||
`test_version` String, | ||
`test_runtime` Float32, | ||
`architecture` String, | ||
`engine_name` String, | ||
`engine_version` String, | ||
`blocking_type` String, | ||
`test_helper_address` LowCardinality(String), | ||
`test_helper_type` LowCardinality(String), | ||
`ooni_run_link_id` Nullable(UInt64) | ||
) | ||
ENGINE = ReplacingMergeTree | ||
ORDER BY (measurement_start_time, report_id, input) | ||
SETTINGS index_granularity = 8192; | ||
|
||
CREATE TABLE IF NOT EXISTS default.jsonl | ||
( | ||
`report_id` String, | ||
`input` String, | ||
`s3path` String, | ||
`linenum` Int32, | ||
`measurement_uid` String | ||
) | ||
ENGINE = MergeTree | ||
ORDER BY (report_id, input) | ||
SETTINGS index_granularity = 8192; | ||
|
||
CREATE TABLE IF NOT EXISTS default.url_priorities ( | ||
`sign` Int8, | ||
`category_code` String, | ||
`cc` String, | ||
`domain` String, | ||
`url` String, | ||
`priority` Int32 | ||
) | ||
ENGINE = CollapsingMergeTree(sign) | ||
ORDER BY (category_code, cc, domain, url, priority) | ||
SETTINGS index_granularity = 1024; | ||
|
||
CREATE TABLE IF NOT EXISTS default.citizenlab | ||
( | ||
`domain` String, | ||
`url` String, | ||
`cc` FixedString(32), | ||
`category_code` String | ||
) | ||
ENGINE = ReplacingMergeTree | ||
ORDER BY (domain, url, cc, category_code) | ||
SETTINGS index_granularity = 4; | ||
|
||
CREATE TABLE IF NOT EXISTS default.citizenlab_flip AS default.citizenlab; | ||
|
||
CREATE TABLE IF NOT EXISTS test_groups ( | ||
`test_name` String, | ||
`test_group` String | ||
) | ||
ENGINE = Join(ANY, LEFT, test_name); | ||
|
||
|
||
-- Auth | ||
|
||
CREATE TABLE IF NOT EXISTS accounts | ||
( | ||
`account_id` FixedString(32), | ||
`role` String | ||
) | ||
ENGINE = EmbeddedRocksDB | ||
PRIMARY KEY account_id; | ||
|
||
CREATE TABLE IF NOT EXISTS session_expunge | ||
( | ||
`account_id` FixedString(32), | ||
`threshold` DateTime DEFAULT now() | ||
) | ||
ENGINE = EmbeddedRocksDB | ||
PRIMARY KEY account_id; | ||
|
||
-- Materialized views | ||
|
||
CREATE MATERIALIZED VIEW IF NOT EXISTS default.counters_test_list | ||
( | ||
`day` DateTime, | ||
`probe_cc` String, | ||
`input` String, | ||
`msmt_cnt` UInt64 | ||
) | ||
ENGINE = SummingMergeTree | ||
PARTITION BY day | ||
ORDER BY (probe_cc, input) | ||
SETTINGS index_granularity = 8192 AS | ||
SELECT | ||
toDate(measurement_start_time) AS day, | ||
probe_cc, | ||
input, | ||
count() AS msmt_cnt | ||
FROM default.fastpath | ||
INNER JOIN default.citizenlab ON fastpath.input = citizenlab.url | ||
WHERE (measurement_start_time < now()) AND (measurement_start_time > (now() - toIntervalDay(8))) AND (test_name = 'web_connectivity') | ||
GROUP BY | ||
day, | ||
probe_cc, | ||
input; | ||
|
||
CREATE MATERIALIZED VIEW IF NOT EXISTS default.counters_asn_test_list | ||
( | ||
`week` DateTime, | ||
`probe_cc` String, | ||
`probe_asn` UInt32, | ||
`input` String, | ||
`msmt_cnt` UInt64 | ||
) | ||
ENGINE = SummingMergeTree | ||
ORDER BY (probe_cc, probe_asn, input) | ||
SETTINGS index_granularity = 8192 AS | ||
SELECT | ||
toStartOfWeek(measurement_start_time) AS week, | ||
probe_cc, | ||
probe_asn, | ||
input, | ||
count() AS msmt_cnt | ||
FROM default.fastpath | ||
INNER JOIN default.citizenlab ON fastpath.input = citizenlab.url | ||
WHERE (measurement_start_time < now()) AND (measurement_start_time > (now() - toIntervalDay(8))) AND (test_name = 'web_connectivity') | ||
GROUP BY | ||
week, | ||
probe_cc, | ||
probe_asn, | ||
input; | ||
|
||
CREATE TABLE IF NOT EXISTS msmt_feedback | ||
( | ||
`measurement_uid` String, | ||
`account_id` String, | ||
`status` String, | ||
`update_time` DateTime64(3) MATERIALIZED now64() | ||
) | ||
ENGINE = ReplacingMergeTree | ||
ORDER BY (measurement_uid, account_id) | ||
SETTINGS index_granularity = 4; | ||
|
||
CREATE TABLE IF NOT EXISTS default.fingerprints_dns | ||
( | ||
`name` String, | ||
`scope` Enum8('nat' = 1, 'isp' = 2, 'prod' = 3, 'inst' = 4, 'vbw' = 5, 'fp' = 6), | ||
`other_names` String, | ||
`location_found` String, | ||
`pattern_type` Enum8('full' = 1, 'prefix' = 2, 'contains' = 3, 'regexp' = 4), | ||
`pattern` String, | ||
`confidence_no_fp` UInt8, | ||
`expected_countries` String, | ||
`source` String, | ||
`exp_url` String, | ||
`notes` String | ||
) | ||
ENGINE = EmbeddedRocksDB | ||
PRIMARY KEY name; | ||
|
||
CREATE TABLE IF NOT EXISTS default.fingerprints_http | ||
( | ||
`name` String, | ||
`scope` Enum8('nat' = 1, 'isp' = 2, 'prod' = 3, 'inst' = 4, 'vbw' = 5, 'fp' = 6, 'injb' = 7, 'prov' = 8), | ||
`other_names` String, | ||
`location_found` String, | ||
`pattern_type` Enum8('full' = 1, 'prefix' = 2, 'contains' = 3, 'regexp' = 4), | ||
`pattern` String, | ||
`confidence_no_fp` UInt8, | ||
`expected_countries` String, | ||
`source` String, | ||
`exp_url` String, | ||
`notes` String | ||
) | ||
ENGINE = EmbeddedRocksDB | ||
PRIMARY KEY name; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
services: | ||
fastpath: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
container_name: ooni-fastpath | ||
ports: | ||
- "5000:5000" | ||
- "8472:8472" | ||
volumes: | ||
- .:/app | ||
working_dir: /app | ||
profiles: | ||
- default | ||
- all | ||
|
||
# This service is used only for testing, in prod we use the actual clickhouse db | ||
clickhouse-server: | ||
image: clickhouse/clickhouse-server:latest | ||
container_name: clickhouse-server | ||
environment: | ||
- CLICKHOUSE_DB=default | ||
- CLICKHOUSE_USER=default | ||
- CLICKHOUSE_PASSWORD=default | ||
ports: | ||
- "9000:9000" | ||
- "8123:8123" | ||
- "9009:9009" | ||
volumes: | ||
- ./clickhouse_init.sql:/docker-entrypoint-initdb.d/init.sql | ||
healthcheck: | ||
test: ["CMD", "clickhouse-client", "--query", "select 1;"] | ||
interval: 30s | ||
retries: 3 | ||
start_period: 60s | ||
timeout: 10s | ||
profiles: | ||
- all | ||
- clickhouse | ||
|
||
volumes: | ||
clickhouse-data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This is the default configration file used by Docker. Replace it or modify it to | ||
# to set up docker | ||
[DEFAULT] | ||
# Collector hostnames, comma separated | ||
collectors = localhost | ||
|
||
# Database connection URI | ||
db_uri = postgresql://readonly@localhost/metadb | ||
|
||
# S3 access credentials | ||
s3_access_key = | ||
s3_secret_key = | ||
|
||
|
||
clickhouse_url = clickhouse://default:default@clickhouse-server:9000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
services: | ||
fastpath: | ||
build: | ||
context: ../../ | ||
dockerfile: Dockerfile | ||
ports: | ||
- "5000" | ||
- "8472" | ||
working_dir: /app | ||
depends_on: | ||
clickhouse-server: | ||
condition: service_healthy | ||
|
||
clickhouse-server: | ||
image: clickhouse/clickhouse-server:latest | ||
environment: | ||
- CLICKHOUSE_USER=default | ||
- CLICKHOUSE_PASSWORD=default | ||
ports: | ||
- "9000" | ||
- "8123" | ||
- "9009" | ||
volumes: | ||
- ../../clickhouse_init.sql:/docker-entrypoint-initdb.d/init.sql | ||
healthcheck: | ||
test: ["CMD", "clickhouse-client", "--query", "select 1;"] | ||
interval: 30s | ||
retries: 3 | ||
start_period: 60s | ||
timeout: 10s |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.