Skip to content

Commit

Permalink
feat: add apache file server (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa authored Apr 26, 2024
1 parent 9139f4b commit 205256a
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/tests/apache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
additional_services:
- apache
1 change: 1 addition & 0 deletions .github/tests/mix-with-tools-mev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ additional_services:
- blockscout
- dugtrio
- blutgang
- apache
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
mev_type: full
Expand Down
1 change: 1 addition & 0 deletions .github/tests/mix-with-tools-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ additional_services:
- blockscout
- dugtrio
- blutgang
- apache
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
keymanager_enabled: true
1 change: 1 addition & 0 deletions .github/tests/mix-with-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ additional_services:
- blockscout
- dugtrio
- blutgang
- apache
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
keymanager_enabled: true
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ For example, to retrieve the Execution Layer (EL) genesis data, run:
kurtosis files download my-testnet el-genesis-data ~/Downloads
```

# Basic file sharing

Apache is included in the package to allow for basic file sharing. The Apache service is started when additional services are enabled. It will expose the network-configs directory, which might needed if you want to share the network config publicly.

```yaml
additional_services:
- apache
```

## Configuration

To configure the package behaviour, you can modify your `network_params.yaml` file. The full YAML schema that can be passed in is as follows with the defaults provided:
Expand Down Expand Up @@ -544,6 +553,7 @@ additional_services:
- blobscan
- dugtrio
- blutgang
- apache
# Configuration place for transaction spammer - https:#github.com/MariusVanDerWijden/tx-fuzz
tx_spammer_params:
Expand Down
9 changes: 9 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dora = import_module("./src/dora/dora_launcher.star")
dugtrio = import_module("./src/dugtrio/dugtrio_launcher.star")
blutgang = import_module("./src/blutgang/blutgang_launcher.star")
blobscan = import_module("./src/blobscan/blobscan_launcher.star")
apache = import_module("./src/apache/apache_launcher.star")
full_beaconchain_explorer = import_module(
"./src/full_beaconchain/full_beaconchain_launcher.star"
)
Expand Down Expand Up @@ -419,6 +420,14 @@ def run(plan, args={}):
global_node_selectors,
)
plan.print("Successfully launched blobscan")
elif additional_service == "apache":
plan.print("Launching apache")
apache.launch_apache(
plan,
el_cl_data_files_artifact_uuid,
global_node_selectors,
)
plan.print("Successfully launched apache")
elif additional_service == "full_beaconchain_explorer":
plan.print("Launching full-beaconchain-explorer")
full_beaconchain_explorer_config_template = read_file(
Expand Down
84 changes: 84 additions & 0 deletions src/apache/apache_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
shared_utils = import_module("../shared_utils/shared_utils.star")
static_files = import_module("../static_files/static_files.star")
constants = import_module("../package_io/constants.star")
SERVICE_NAME = "apache"
HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 80

APACHE_CONFIG_FILENAME = "index.html"

APACHE_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/usr/local/apache2/htdocs/"

# The min/max CPU/memory that assertoor can use
MIN_CPU = 100
MAX_CPU = 300
MIN_MEMORY = 128
MAX_MEMORY = 256

USED_PORTS = {
HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
)
}


def launch_apache(
plan,
el_cl_genesis_data,
global_node_selectors,
):
config_files_artifact_name = plan.upload_files(
src=static_files.APACHE_CONFIG_FILEPATH, name="apache-config"
)

config = get_config(
config_files_artifact_name,
el_cl_genesis_data,
global_node_selectors,
)

plan.add_service(SERVICE_NAME, config)


def get_config(
config_files_artifact_name,
el_cl_genesis_data,
node_selectors,
):
files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data,
APACHE_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
}

cmd = [
"echo",
"AddType application/octet-stream .tar",
">>",
"/usr/local/apache2/conf/httpd.conf",
"&&",
"tar",
"-czvf",
"/usr/local/apache2/htdocs/network-config.tar",
"-C",
"/network-configs/",
".",
"&&",
"httpd-foreground",
]

cmd_str = " ".join(cmd)

return ServiceConfig(
image="httpd:latest",
ports=USED_PORTS,
cmd=[cmd_str],
entrypoint=["sh", "-c"],
files=files,
min_cpu=MIN_CPU,
max_cpu=MAX_CPU,
min_memory=MIN_MEMORY,
max_memory=MAX_MEMORY,
node_selectors=node_selectors,
)
2 changes: 2 additions & 0 deletions src/static_files/static_files.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ VALIDATOR_RANGES_CONFIG_TEMPLATE_FILEPATH = (
STATIC_FILES_DIRPATH + "/validator-ranges/config.yaml.tmpl"
)

APACHE_CONFIG_FILEPATH = STATIC_FILES_DIRPATH + "/apache-config/index.html"

DORA_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dora-config/config.yaml.tmpl"
DUGTRIO_CONFIG_TEMPLATE_FILEPATH = (
STATIC_FILES_DIRPATH + "/dugtrio-config/config.yaml.tmpl"
Expand Down
50 changes: 50 additions & 0 deletions static_files/apache-config/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to My Website</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
text-align: center;
}
.download-btn {
display: block;
width: 200px;
margin: 20px auto;
padding: 10px;
text-align: center;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
text-decoration: none; /* Remove underline */
}
.download-btn:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Kurtosis File sharing site</h1>
<a href="network-config.tar" class="download-btn">Download network configs</a>
</div>
</body>
</html>

0 comments on commit 205256a

Please sign in to comment.