test
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Steve McMaster 2023-10-17 00:36:06 -04:00
parent 17b0e1b895
commit 15f47ca582
4 changed files with 139 additions and 29 deletions

View File

@ -1,27 +1,58 @@
TEMPLATES = {
"_distro": {
"alpine": {
"distro_name": "Alpine Linux",
"distro_shortname": "alpine",
"distro_package_manager": "apk",
"distro_releases": ["3.17", "3.18", "edge"],
"image": "cr.smcm.xyz/coder-images/alpine",
},
"aports": {
"distro_name": "Alpine Linux",
"distro_shortname": "alpine",
"distro_package_manager": "apk",
"distro_releases": ["edge"],
"image": "cr.smcm.xyz/coder-images/alpine",
},
"ubuntu": {
"distro_name": "Ubuntu Linux",
"distro_shortname": "ubuntu",
"distro_package_manager": "apk",
"distro_releases": ["20.04", "22.04", "23.04", "23.10"],
"image": "cr.smcm.xyz/coder-images/ubuntu",
},
},
"_lang": {
"eclipse-temurin": {
"lang": "eclipse-temurin",
"versions": ["11-jdk", "17-jdk", "21-jdk"],
"container_base_choices": [
{"label": "Ubuntu Jammy", "suffix": ""},
"distro_choices": [
{"label": "Ubuntu", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
"golang": {
"lang": "golang",
"versions": ["1.21"],
"distro_choices": [
{"label": "Debian", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
"gradle": {
"lang": "gradle",
"versions": ["8.3-jdk17"],
"coder_user": "gradle",
"distro_choices": [
{"label": "Debian", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
"maven": {
"lang": "eclipse-temurin-maven",
"versions": ["11", "17", "21"],
"container_base_choices": [
{"label": "Ubuntu Focal", "suffix": ""},
"distro_choices": [
{"label": "Ubuntu", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
@ -29,25 +60,26 @@ TEMPLATES = {
"lang": "node",
"versions": ["18", "20"],
"coder_user": "node",
"distro_choices": [
{"label": "Debian", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
"python": {
"lang": "python",
"versions": ["3.8", "3.11"],
"distro_choices": [
{"label": "Debian", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
"rust": {
"lang": "rust",
"versions": ["1.71"],
},
},
"alpine": {
"alpine": {
"image": "cr.smcm.xyz/coder-images/alpine",
"alpine_releases": ["3.17", "3.18", "edge"],
},
"aports": {
"image": "cr.smcm.xyz/coder-images/alpine",
"alpine_releases": ["edge"],
"feature_flags": {"aports": True}
"distro_choices": [
{"label": "Debian", "suffix": ""},
{"label": "Alpine Linux", "suffix": "-alpine"},
]
},
},
"android": {
@ -83,12 +115,6 @@ TEMPLATES = {
"terraform_versions": ["1.6"],
},
},
"ubuntu": {
"ubuntu": {
"image": "cr.smcm.xyz/coder-images/ubuntu",
"ubuntu_releases": ["20.04", "22.04", "23.04", "23.10"],
},
},
}
def main(ctx):

53
_distro.jinja Normal file
View File

@ -0,0 +1,53 @@
{% extends "base.tf.jinja" %}
{% block parameters %}
{{ super() }}
data "coder_parameter" "distro_release" {
name = "{{ distro_name }} Release"
description = "{{ distro_name }} Release"
type = "string"
default = ""
mutable = true
option {
name = "Latest"
value = ""
}
{% for version in distro_releases %}
option {
name = "{{ version["name"] }}"
value = {% if "suffix" in version %}"-{{ version["suffix"] }}"{% else %}""{% endif %}
}
{% endfor %}
}
{% endblock %}
{% block kubernetes_pod_main_image %}
image = "{{image}}${data.coder_parameter.distro_release.value}:latest"
{% endblock %}
{% block post_startup_script_setup_home %}
{% if feature_flags is defined %}
{% for feature_flag in feature_flags %}
{% set template = distro_shortname + "/" + feature_flag + ".tf.jinja" %}
{% inlcude template %}
{% endfor %}
{% endif %}
{% endblock %}
{% block startup_script_install_packages %}
{% if distro_package_manager == "apt" %}
sudo apt update
{% if packages_to_install is defined %}
sudo apt install {{ packages_to_install | join(" ") }}
{% endif %}
{% elif distro_package_manager == "apk" %}
sudo apk update
{% if packages_to_install is defined %}
sudo apk add {{ packages_to_install | join(" ") }}
{% endif %}
{% endif %}
{% endblock %}

View File

@ -1,9 +1,5 @@
{% extends "base.tf.jinja" %}
{% if container_base_choices is not defined %}
{% set container_base_choices = [{"label": "Debian Linux", "suffix": ""}, {"label": "Alpine Linux", "suffix": "-alpine"}] %}
{% endif %}
{% block parameters %}
{{ super() }}
@ -30,12 +26,12 @@ data "coder_parameter" "container_base" {
name = "Container Base"
description = "Container Base"
type = "string"
default = "{{ container_base_choices[0]["suffix"] }}"
default = "{{ distro_choices[0]["suffix"] }}"
mutable = false
{% for container_base_choice in container_base_choices %}
{% for distro_choice in distro_choices %}
option {
name = "{{ container_base_choice["label"] }}"
value = "{{ container_base_choice["suffix"] }}"
name = "{{ distro_choice["label"] }}"
value = "{{ distro_choice["suffix"] }}"
}
{% endfor %}
}

35
alpine/aports.tf.jinja Normal file
View File

@ -0,0 +1,35 @@
# Ensure host key verification passes
if [ ! -f .ssh/known_hosts ]; then
mkdir -p .ssh
ssh-keyscan gitlab.alpinelinux.org > .ssh/known_hosts
fi
# Clone the aports repository
if [ ! -d aports/.git ]; then
git clone git@gitlab.alpinelinux.org:alpine/aports.git
git config remote.origin.pushurl git@gitlab.alpinelinux.org:mcm/aports.git
else
(
cd aports
git remote set-url origin git@gitlab.alpinelinux.org:alpine/aports.git
git config remote.origin.pushurl git@gitlab.alpinelinux.org:mcm/aports.git
)
fi
# Generate abuild keys if needed
if [ ! -f "$HOME/.abuild/abuild.conf" ]; then
abuild-keygen -a -i -n
fi
[ -e "$HOME/.abuild/abuild.conf" ] && . $HOME/.abuild/abuild.conf
if [ -n "$PACKAGER_PRIVKEY" ]; then
sudo cp $PACKAGER_PRIVKEY /etc/apk/keys/
fi
# Update apk
for repo in main community testing ; do
REPO="$HOME/packages/$repo"
grep -q "^$REPO" /etc/apk/repositories || (echo $REPO | sudo tee -a /etc/apk/repositories)
done
sudo apk update