Skip to content
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

Refactor Template JSON #183

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
FROM nginx:stable-alpine
FROM alpine:3.18 AS builder

COPY templates.json /usr/share/nginx/html/templates.json
COPY containers /containers
COPY stacks /stacks
COPY build.sh /build.sh

RUN apk add --no-cache bash jq && \
/build.sh && \
/build.sh 1.20.0 && \
/build.sh 2.0

FROM nginx:stable-alpine as image

COPY --from=builder templates.json /usr/share/nginx/html/templates.json
COPY --from=builder templates-1.20.0.json /usr/share/nginx/html/templates-1.20.0.json
COPY --from=builder templates-2.0.json /usr/share/nginx/html/templates-2.0.json

EXPOSE 80
35 changes: 35 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [ -n "$1" ]; then
template_version="-$1"
else
template_version=""
fi

metadata_directory="./containers ./stacks"
output_file="./templates${template_version}.json"
metadata_list=()

for dir in $metadata_directory; do
# Iterate over each directory and file
while IFS= read -r -d '' file; do
if [[ $file == */metadata${template_version}.json ]]; then
metadata=$(cat "$file")
metadata_list+=("$metadata")
fi
done < <(find "$dir" -type f -name "metadata${template_version}.json" -print0)
done

# Combine metadata list into a single JSON array
metadata_json=$(printf '%s\n' "${metadata_list[@]}" | jq -s '.')

# Create the final JSON string with the desired format
if [ "$1" == "2.0" ]; then
final_json=$(printf '{"version": "2","templates": %s}\n' "$metadata_json")
else
final_json=$metadata_json
fi


# Write the combined metadata to the templates.json file
echo "$final_json" > "$output_file"
21 changes: 21 additions & 0 deletions containers/caddy/metadata-1.20.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": 1,
"title": "Caddy",
"description": "HTTP/2 web server with automatic HTTPS",
"categories": [
"webserver"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/caddy.png",
"image": "abiosoft/caddy:latest",
"ports": [
"80/tcp",
"443/tcp",
"2015/tcp"
],
"volumes": [
{
"container": "/root/.caddy"
}
]
}
19 changes: 19 additions & 0 deletions containers/caddy/metadata-2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": 1,
"title": "Caddy",
"description": "Open-source web server with automatic HTTPS written in Go",
"categories": [
"webserver"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/caddy.png",
"image": "caddy:latest",
"ports": [
"80/tcp"
],
"volumes": [
{
"container": "/data"
}
]
}
19 changes: 19 additions & 0 deletions containers/caddy/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "container",
"title": "Caddy",
"description": "HTTP/2 web server with automatic HTTPS",
"categories": [
"webserver"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/caddy.png",
"image": "abiosoft/caddy:latest",
"ports": [
"80/tcp",
"443/tcp",
"2015/tcp"
],
"volumes": [
"/root/.caddy"
]
}
21 changes: 21 additions & 0 deletions containers/cockroachdb/metadata-1.20.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": 1,
"title": "CockroachDB",
"description": "An open-source, survivable, strongly consistent, scale-out SQL database",
"categories": [
"database"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/cockroachdb.png",
"image": "cockroachdb/cockroach:latest",
"ports": [
"26257/tcp",
"8080/tcp"
],
"volumes": [
{
"container": "/cockroach/cockroach-data"
}
],
"command": "start --insecure"
}
19 changes: 19 additions & 0 deletions containers/cockroachdb/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "container",
"title": "CockroachDB",
"description": "An open-source, survivable, strongly consistent, scale-out SQL database",
"categories": [
"database"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/cockroachdb.png",
"image": "cockroachdb/cockroach:latest",
"ports": [
"26257/tcp",
"8080/tcp"
],
"volumes": [
"/cockroach/cockroach-data"
],
"command": "start --insecure"
}
21 changes: 21 additions & 0 deletions containers/commandbox/metadata-1.20.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": 1,
"title": "CommandBox",
"description": "ColdFusion (CFML) CLI",
"categories": [
"development"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-commandbox.png",
"image": "ortussolutions/commandbox:latest",
"env": [
{
"name": "CFENGINE",
"set": "[email protected]"
}
],
"ports": [
"8080/tcp",
"8443/tcp"
]
}
22 changes: 22 additions & 0 deletions containers/commandbox/metadata-2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"type": 1,
"title": "CommandBox",
"description": "ColdFusion (CFML) CLI",
"categories": [
"development"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-commandbox.png",
"image": "ortussolutions/commandbox:latest",
"env": [
{
"name": "CFENGINE",
"default": "[email protected]",
"preset": true
}
],
"ports": [
"8080/tcp",
"8443/tcp"
]
}
21 changes: 21 additions & 0 deletions containers/commandbox/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "container",
"title": "CommandBox",
"description": "ColdFusion (CFML) CLI",
"categories": [
"development"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-commandbox.png",
"image": "ortussolutions/commandbox:latest",
"env": [
{
"name": "CFENGINE",
"set": "[email protected]"
}
],
"ports": [
"8080/tcp",
"8443/tcp"
]
}
37 changes: 37 additions & 0 deletions containers/contentbox/metadata-1.20.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"type": 1,
"title": "ContentBox",
"description": "Open-source modular CMS",
"categories": [
"CMS"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-contentbox.png",
"image": "ortussolutions/contentbox:latest",
"env": [
{
"name": "express",
"set": "true"
},
{
"name": "install",
"set": "true"
},
{
"name": "CFENGINE",
"set": "[email protected]"
}
],
"ports": [
"8080/tcp",
"8443/tcp"
],
"volumes": [
{
"container": "/data/contentbox/db"
},
{
"container": "/app/includes/shared/media"
}
]
}
40 changes: 40 additions & 0 deletions containers/contentbox/metadata-2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"type": 1,
"title": "ContentBox",
"description": "Open-source modular CMS",
"categories": [
"CMS"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-contentbox.png",
"image": "ortussolutions/contentbox:latest",
"env": [
{
"name": "express",
"default": "true",
"preset": true
},
{
"name": "install",
"default": "true",
"preset": true
},
{
"name": "CFENGINE",
"default": "[email protected]",
"preset": true
}
],
"ports": [
"8080/tcp",
"8443/tcp"
],
"volumes": [
{
"container": "/data/contentbox/db"
},
{
"container": "/app/includes/shared/media"
}
]
}
33 changes: 33 additions & 0 deletions containers/contentbox/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": "container",
"title": "ContentBox",
"description": "Open-source modular CMS",
"categories": [
"CMS"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/ortussolutions-contentbox.png",
"image": "ortussolutions/contentbox:latest",
"env": [
{
"name": "express",
"set": "true"
},
{
"name": "install",
"set": "true"
},
{
"name": "CFENGINE",
"set": "[email protected]"
}
],
"ports": [
"8080/tcp",
"8443/tcp"
],
"volumes": [
"/data/contentbox/db",
"/app/includes/shared/media"
]
}
20 changes: 20 additions & 0 deletions containers/cratedb/metadata-1.20.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": 1,
"title": "CrateDB",
"description": "An open-source distributed SQL database",
"categories": [
"database"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/cratedb.png",
"image": "crate:latest",
"ports": [
"4200/tcp",
"4300/tcp"
],
"volumes": [
{
"container": "/data"
}
]
}
20 changes: 20 additions & 0 deletions containers/cratedb/metadata-2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": 1,
"title": "CrateDB",
"description": "An open-source distributed SQL database",
"categories": [
"database"
],
"platform": "linux",
"logo": "https://portainer-io-assets.sfo2.digitaloceanspaces.com/logos/cratedb.png",
"image": "crate:latest",
"ports": [
"4200/tcp",
"4300/tcp"
],
"volumes": [
{
"container": "/data"
}
]
}
Loading