Skip to content

Commit

Permalink
Created script tools/environments.py to generate static/data/environm…
Browse files Browse the repository at this point in the history
…ents.json using environments.json from environments repo. (#265)

Modified environments javascript file to point to our latest images in GHCR for Go, Python, NodeJS and binary environments.

Signed-off-by: Md Soharab Ansari <[email protected]>
  • Loading branch information
soharab-ic authored Aug 30, 2024
1 parent d7d67b7 commit 175ac71
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 124 deletions.
18 changes: 13 additions & 5 deletions content/en/environments/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,19 @@ <h5><label class="d-block" for="filter-lang">Filter by language</label></h5>
document.getElementById("filter-lang").innerHTML = languageOptions.join(' ');

function getBadge(imageName) {
return `<h4 class="d-inline-block mx-1 my-0">
<a href="https://hub.docker.com/r/fission/${imageName}" class="badge badge-light text-wrap" target="_blank">
${imageName}
</a>
</h4>`
if (imageName.includes("node") || imageName.includes("python") || imageName.includes("go") || imageName.includes("binary")) {
return `<h4 class="d-inline-block mx-1 my-0">
<a href="https://github.com/fission/environments/pkgs/container/${imageName}" class="badge badge-light text-wrap" target="_blank">
${imageName}
</a>
</h4>`
} else {
return `<h4 class="d-inline-block mx-1 my-0">
<a href="https://hub.docker.com/r/fission/${imageName}" class="badge badge-light text-wrap" target="_blank">
${imageName}
</a>
</h4>`
}
}

function updateEnvItems() {
Expand Down
259 changes: 140 additions & 119 deletions static/data/environments.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,142 @@
[
{
"name": "Node.js",
"logo": "/images/lang-logo/nodejs-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/nodejs",
"images": [
{ "main": "node-env", "builder": "node-builder" },
{ "main": "node-env-16", "builder": "node-builder-16" },
{ "main": "node-env-14", "builder": "node-builder-14" },
{ "main": "node-env-12.16", "builder": "node-builder-12.16" },
{ "main": "node-env-12", "builder": "node-builder-12" },
{ "main": "node-env-debian" }
]
},
{
"name": "Go",
"logo": "/images/lang-logo/go-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/go",
"images": [
{ "main": "go-env", "builder": "go-builder" },
{ "main": "go-env-1.17", "builder": "go-builder-1.17" },
{ "main": "go-env-1.16", "builder": "go-builder-1.16" },
{ "main": "go-env-1.15", "builder": "go-builder-1.15" },
{ "main": "go-env-1.14", "builder": "go-builder-1.14" },
{ "main": "go-env-1.13", "builder": "go-builder-1.13" },
{ "main": "go-env-1.12", "builder": "go-builder-1.12" },
{ "main": "go-env-1.11.4", "builder": "go-builder-1.11.4" },
{ "main": "go-env-1.11.4-1.12", "builder": "go-builder-1.11.4-1.12" },
{ "builder": "go-build-env" }
]
},
{
"name": "Python",
"logo": "/images/lang-logo/python-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/python",
"images": [
{ "main": "python3-env", "builder": "python-build-env" },
{ "main": "python-env-3.10", "builder": "python-builder-3.10" },
{ "main": "python-env-3.9", "builder": "python-builder-3.9" },
{ "main": "python-env-3.8", "builder": "python-builder-3.8" },
{ "main": "python-env-3.7", "builder": "python-builder-3.7" },
{ "main": "python-env-2.7", "builder": "python-build-env-2.7" },
{ "main": "python2-env" }
]
},
{
"name": "PHP",
"logo": "/images/lang-logo/php-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/php7",
"images": [
{ "main": "php-env", "builder": "php-builder" }
]
},
{
"name": "Java",
"logo": "/images/lang-logo/java-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/jvm",
"images": [
{ "main": "jvm-env", "builder": "jvm-builder" },
{ "builder": "jvm-env-builder" }
]
},
{
"name": "Java",
"displayName": "Java (JVM-Jersey)",
"logo": "/images/lang-logo/java-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/jvm-jersey",
"images": [
{ "main": "jvm-jersey-env", "builder": "jvm-jersey-builder" },
{ "main": "jvm-jersey-env-11", "builder": "jvm-jersey-builder-11" }
]
},
{
"name": ".NET",
"logo": "/images/lang-logo/dotnet-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/dotnet",
"images": [
{ "main": "dotnet-env" }
]
},
{
"name": ".NET Core",
"logo": "/images/lang-logo/dotnetcore-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/dotnet20",
"images": [
{ "main": "dotnet20-env", "builder": "dotnet20-builder" }
]
},
{
"name": "Perl",
"logo": "/images/lang-logo/perl-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/perl",
"images": [
{ "main": "perl-env" }
]
},
{
"name": "Ruby",
"logo": "/images/lang-logo/ruby-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/ruby",
"images": [
{ "main": "ruby-env", "builder": "ruby-builder" }
]
},
{
"name": "TensorFlow",
"logo": "/images/lang-logo/tensorflow-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/tensorflow-serving",
"images": [
{ "main": "tensorflow-serving-env" }
]
},
{
"name": "Misc",
"displayName": "Binary",
"repo": "https://github.com/fission/environments/tree/master/binary",
"images": [
{ "main": "binary-env", "builder": "binary-builder" }
]
}
{
"name": "Node.js",
"logo": "/images/lang-logo/nodejs-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/nodejs",
"images": [
{
"main": "node-env-debian"
},
{
"main": "node-env-22",
"builder": "node-builder-22"
},
{
"main": "node-env",
"builder": "node-builder"
}
]
},
{
"name": "Go",
"logo": "/images/lang-logo/go-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/go",
"images": [
{
"main": "go-env",
"builder": "go-builder"
},
{
"main": "go-env-1.23",
"builder": "go-builder-1.23"
}
]
},
{
"name": "Python",
"logo": "/images/lang-logo/python-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/python",
"images": [
{
"main": "python-env",
"builder": "python-builder"
}
]
},
{
"name": "PHP",
"logo": "/images/lang-logo/php-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/php7",
"images": [
{
"main": "php-env",
"builder": "php-builder"
}
]
},
{
"name": "Java",
"logo": "/images/lang-logo/java-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/jvm",
"images": [
{
"main": "jvm-env",
"builder": "jvm-builder"
}
]
},
{
"name": "Java (JVM-Jersey)",
"logo": "/images/lang-logo/java-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/jvm-jersey",
"images": [
{
"main": "jvm-jersey-env-11",
"builder": "jvm-jersey-builder-11"
}
]
},
{
"name": ".NET",
"logo": "/images/lang-logo/dotnet-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/dotnet",
"images": [
{
"main": "dotnet-env"
}
]
},
{
"name": ".NET Core",
"logo": "/images/lang-logo/dotnetcore-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/dotnet20",
"images": [
{
"main": "dotnet20-env",
"builder": "dotnet20-builder"
}
]
},
{
"name": "Perl",
"logo": "/images/lang-logo/perl-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/perl",
"images": [
{
"main": "perl-env"
}
]
},
{
"name": "Ruby",
"logo": "/images/lang-logo/ruby-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/ruby",
"images": [
{
"main": "ruby-env",
"builder": "ruby-builder"
}
]
},
{
"name": "TensorFlow",
"logo": "/images/lang-logo/tensorflow-logo.svg",
"repo": "https://github.com/fission/environments/tree/master/tensorflow-serving",
"images": [
{
"main": "tensorflow-serving-env"
}
]
},
{
"name": "Misc",
"displayName": "Binary",
"repo": "https://github.com/fission/environments/tree/master/binary",
"images": [
{
"main": "binary-env",
"builder": "binary-builder"
}
]
}
]
62 changes: 62 additions & 0 deletions tools/environments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import json, sys

env_dict = {
'JVM Environment': 'Java',
'JVM Jersey Environment': 'Java (JVM-Jersey)',
'Ruby Environment': 'Ruby',
'Python Environment': 'Python',
'Fission Binary Environment': 'Misc',
'PHP Environment': 'PHP',
'Dotnet 2 Environment': '.NET Core',
'Go Environment': 'Go',
'Dotnet Environment': '.NET',
'Perl Environment': 'Perl',
'Tensorflow Serving Environment': 'TensorFlow',
'Nodejs Environment': 'Node.js',
}

def load_environment_json(file_name):
"""Read content from a JSON file and return the content as a string."""
with open(file_name, 'r') as f:
# Load the JSON data from the file
return json.load(f)

def create_env_string(src_envs, dst_envs):
for dst_env in dst_envs:
name = dst_env['name']
data_list = []
for src_env in src_envs:
num_envs = len(src_env)
for i in range(0, num_envs):
if name == env_dict[src_env[i]['name']]:
print(name)
if 'image' in src_env[i] and 'builder' in src_env[i]:
data_list.append({
"main": src_env[i]['image'],
"builder": src_env[i]['builder']
})
elif 'image' in src_env[i]:
data_list.append({
"main": src_env[i]['image']
})
elif 'builder' in src_env[i]:
data_list.append({
"builder": src_env[i]['builder']
})
else:
print("image and builder not present for", src_env[i]['name'])
sys.exit(1)
dst_env['images'] = data_list

return dst_envs

def main():
src_envs = load_environment_json('environments.json')
dst_envs = load_environment_json('../static/data/environments.json')

env_json_string = create_env_string(src_envs=src_envs, dst_envs=dst_envs)
with open('../static/data/environments.json', 'w') as file:
json.dump(env_json_string, file, indent=4)

if __name__ == "__main__":
main()

0 comments on commit 175ac71

Please sign in to comment.