-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9139f4b
commit 205256a
Showing
9 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,2 @@ | ||
additional_services: | ||
- apache |
This file contains 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 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 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 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 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 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,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, | ||
) |
This file contains 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 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,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> |