diff --git a/images/base/Dockerfile b/images/base/Dockerfile index efe9150..722d126 100644 --- a/images/base/Dockerfile +++ b/images/base/Dockerfile @@ -59,12 +59,12 @@ RUN usermod -aG docker ${USERNAME} # stuff here ENV BAZEL_BUILDTOOLS_VERSION="6.1.2" -ENV GITHUB_CLI_VERSION="2.28.0" -ENV CODER_CLI_VERSION="0.23.0" +ENV GITHUB_CLI_VERSION="2.29.0" +ENV CODER_CLI_VERSION="0.23.2" ENV TERRAFORM_VERSION="1.4.6" ENV BAZELISK_VERSION="1.16.0" ENV KUBECTL_VERSION="1.27.1" -ENV HELM_VERSION="3.11.3" +ENV HELM_VERSION="3.12.0" # Get current architecture and download software here # also this looks like shit, i know! diff --git a/images/base/README.md b/images/base/README.md index dff6472..b5c8d78 100644 --- a/images/base/README.md +++ b/images/base/README.md @@ -5,22 +5,22 @@ This image is the main base for all of the images in this repository. | Name | Description | Version | | ---------------- | --------------------------------------------------------------------------------- | -------------------------- | | Bazel Buildtools | A bazel BUILD file formatter and editor | [v6.1.2][bazel-buildtools] | -| GitHub CLI | GitHub's official command line utility | [v2.28.0][github-cli] | -| Coder (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.23.0][coder] | +| GitHub CLI | GitHub's official command line utility | [v2.29.0][github-cli] | +| Coder (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.23.2][coder] | | Terraform | Automate Infrastructure on Any Cloud | [v1.4.6][terraform] | | Bazelisk | A user-friendly launcher for Bazel. | [v1.16.0][bazelisk] | | `kubectl` | kubectl controls the Kubernetes cluster manager. | [v1.27.1][kubectl] | -| `bazel` | a fast, scalable, multi-language and extensible build system | [v6.1.2][bazel] | -| `helm` | The Kubernetes Package Manager | [v3.11.3][helm] | +| `bazel` | a fast, scalable, multi-language and extensible build system | [v6.2.0][bazel] | +| `helm` | The Kubernetes Package Manager | [v3.12.0][helm] | -[bazel-buildtools]: https://github.com/bazelbuild/buildtools/releases/tag/6.1.2 -[github-cli]: https://github.com/cli/cli/releases/tag/v2.28.0 +[bazel-buildtools]: https://github.com/bazelbuild/buildtools/releases/tag/v6.1.2 +[github-cli]: https://github.com/cli/cli/releases/tag/v2.29.0 [terraform]: https://github.com/hashicorp/terraform/releases/tag/v1.4.6 [bazelisk]: https://github.com/bazelbuild/bazelisk/releases/tag/v1.16.0 [kubectl]: https://github.com/kubernetes/kubernetes/releases/tag/v1.27.1 -[coder]: https://github.com/coder/coder/releases/tag/v0.23.0 -[bazel]: https://github.com/bazelbuild/bazel/releases/tag/6.1.2 -[helm]: https://github.com/helm/helm/releases/tag/v3.11.3 +[coder]: https://github.com/coder/coder/releases/tag/v0.23.2 +[bazel]: https://github.com/bazelbuild/bazel/releases/tag/6.2.0 +[helm]: https://github.com/helm/helm/releases/tag/v3.12.0 ### Helm Helm comes with Bitnami's charts library preconfigured. diff --git a/images/golang/Dockerfile b/images/golang/Dockerfile index f1b7582..22bf1a2 100644 --- a/images/golang/Dockerfile +++ b/images/golang/Dockerfile @@ -27,8 +27,8 @@ ENV USERNAME=noel USER root # Put versions in environment variables -ENV GOLANG_VERSION="1.20.3" -ENV GORELEASER_VERSION="1.17.2" +ENV GOLANG_VERSION="1.20.4" +ENV GORELEASER_VERSION="1.18.2" ENV GOLANGCI_VERSION="1.52.2" # Install packages here. diff --git a/images/golang/README.md b/images/golang/README.md index f58d912..4247bb8 100644 --- a/images/golang/README.md +++ b/images/golang/README.md @@ -4,10 +4,10 @@ This is the Docker image that bundles the Go compiler with **goreleaser** and ** ## Bundled Software | Name | Description | Version | | ---------- | -------------------------------------------------- | --------------------- | -| Go | The Go programming language | [v1.20.3][golang] | -| GoReleaser | Deliver Go binaries as fast and easily as possible | [v1.17.2][goreleaser] | +| Go | The Go programming language | [v1.20.4][golang] | +| GoReleaser | Deliver Go binaries as fast and easily as possible | [v1.18.2][goreleaser] | | Golang CI | Fast linters Runner for Go | [v1.52.2][golangci] | -[goreleaser]: https://github.com/goreleaser/goreleaser/releases/tag/v1.17.2 +[goreleaser]: https://github.com/goreleaser/goreleaser/releases/tag/v1.18.2 [golangci]: https://github.com/golangci/golangci-lint/releases/tag/v1.52.2 -[golang]: https://github.com/golang/go/releases/tag/go1.20.3 +[golang]: https://github.com/golang/go/releases/tag/go1.20.4 diff --git a/images/java/Dockerfile b/images/java/Dockerfile index 1962c5b..58b74a4 100644 --- a/images/java/Dockerfile +++ b/images/java/Dockerfile @@ -19,8 +19,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# use April 26th image (since Adoptium doesn't support Ubuntu Lunar yet) -FROM ghcr.io/auguwu/coder-images/base:2023.04.26 +FROM ghcr.io/auguwu/coder-images/base ENV USERNAME=noel @@ -29,14 +28,16 @@ USER root # Set version environment variables ENV GRADLE_VERSION="8.1.1" -ENV MAVEN_VERSION="3.9.1" +ENV MAVEN_VERSION="3.9.2" # install required things RUN DEBIAN_FRONTEND="noninteractive" apt install -y wget libarchive-tools -# Install Temurin 19 +# Install Temurin JDK 20 RUN wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add - -RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list + +# force it to use the Kinetic repository until it supports 23.04 +RUN echo "deb https://packages.adoptium.net/artifactory/deb kinetic main" | sudo tee /etc/apt/sources.list.d/adoptium.list RUN DEBIAN_FRONTEND="noninteractive" apt update && \ DEBIAN_FRONTEND="noninteractive" apt install -y temurin-20-jdk diff --git a/images/java/README.md b/images/java/README.md index e56f315..6d5b885 100644 --- a/images/java/README.md +++ b/images/java/README.md @@ -6,8 +6,8 @@ This image extends the [base image](https://github.com/auguwu/coder-images/pkgs/ | ------ | --------------------------------------------------- | ------------------------------- | | JDK | The Java development kit. | [jdk-20.0.1+9][temurin-release] | | Gradle | Adaptable, fast automation for all | [v8.1.1][gradle-release] | -| Maven | Software project management and comprehension tool. | [v3.9.1][maven-release] | +| Maven | Software project management and comprehension tool. | [v3.9.2][maven-release] | [temurin-release]: https://github.com/adoptium/temurin20-binaries/releases/tag/jdk-20.0.1%2B9 [gradle-release]: https://github.com/gradle/gradle/releases/tag/v8.1.1 -[maven-release]: https://github.com/apache/maven/releases/tag/maven-3.9.1 +[maven-release]: https://github.com/apache/maven/releases/tag/maven-3.9.2 diff --git a/images/node/Dockerfile b/images/node/Dockerfile index ab4648c..3919a44 100644 --- a/images/node/Dockerfile +++ b/images/node/Dockerfile @@ -27,7 +27,7 @@ ENV USERNAME=noel USER root # versions here -ENV NODE_VERSION="20.0.0" +ENV NODE_VERSION="20.1.0" # Install xz-utils so we can unpack the Node.js installation RUN DEBIAN_FRONTEND="noninteractive" apt install -y xz-utils diff --git a/images/node/README.md b/images/node/README.md index 9867a1a..b233296 100644 --- a/images/node/README.md +++ b/images/node/README.md @@ -4,6 +4,6 @@ This image extends from the [base image](https://github.com/auguwu/coder-images/ ## Bundled Software | Name | Description | Version | | ------- | ----------------------------------- | ---------------- | -| Node.js | Node.js JavaScript runtime ✨🐢🚀✨ | [v20.0.0][node] | +| Node.js | Node.js JavaScript runtime ✨🐢🚀✨ | [v20.1.0][node] | -[node]: https://github.com/nodejs/node/releases/v20.0.0 +[node]: https://github.com/nodejs/node/releases/v20.1.0 diff --git a/template/main.tf b/template/main.tf index 36ac6b4..f3c138f 100644 --- a/template/main.tf +++ b/template/main.tf @@ -46,31 +46,39 @@ data "coder_workspace" "me" { resource "coder_agent" "main" { arch = "amd64" - dir = var.home_dir + dir = data.coder_parameter.volume_dir.value os = "linux" metadata { display_name = "Processes" - key = "proc_count" + interval = 1 + timeout = 1 script = "ps aux | wc -l" + key = "proc_count" + } + + metadata { + display_name = "CPU Usage" interval = 1 timeout = 1 + script = "vmstat | awk 'FNR==3 {printf \"%2.0f%%\", $13+14+16}'" + key = "cpu" } metadata { display_name = "Load Average" - key = "load" - script = "awk '{print $1}' /proc/loadavg" interval = 1 timeout = 1 + script = "awk '{print $1}' /proc/loadavg" + key = "load" } metadata { display_name = "Disk Usage" - key = "disk" - script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'" interval = 1 timeout = 1 + script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'" + key = "disk" } metadata { @@ -81,10 +89,18 @@ resource "coder_agent" "main" { key = "containers" } + metadata { + display_name = "Memory Usage" + interval = 1 + timeout = 1 + script = "free | awk '/^Mem/ { printf(\"%.0f%%\", $4/$2 * 100.0) }'" + key = "memory" + } + startup_script = <<-EOL #!/bin/bash # Fix folder permissions since root owns /home/noel for some reason??? - sudo chown -R noel:noel /home/noel + sudo chown -R $USER:$USER /home/$USER if [ ! -f ~/.profile ]; then cp /etc/skel/.profile $HOME/.profile @@ -110,37 +126,29 @@ resource "coder_agent" "main" { sleep 1 done - # Install code-server if enabled - ${var.install_codeserver == true ? "curl -fsSL https://code-server.dev/install.sh | sh" : ""} - ${var.install_codeserver == true ? "code-server --auth none --port 3621 > /dev/null 2>&1 &" : ""} - # Clone the given repository if needed - if ! [ -d "${var.workspace_dir}" ]; then - ${var.git_repository != "" ? "git clone ${var.git_repository} ${var.workspace_dir}" : ""} - fi - - if ! [ -d "${var.workspace_dir}" ]; then - mkdir ${var.workspace_dir} + if ! [ -d "${data.coder_parameter.workspace.value}" ]; then + ${data.coder_parameter.git_repository.value != "" ? "git clone ${data.coder_parameter.git_repository.value} ${data.coder_parameter.workspace.value}" : "mkdir ${data.coder_parameter.workspace.value}"} fi - if [ -n "${var.docker_network_name}" ]; then - docker network create "${var.docker_network_name}" --driver=bridge >/dev/null 2>&1 - echo "Created Docker network \`${var.docker_network_name}\`, you can use it with .coder/docker-compose.yml as a external network!" + if [ -n "${data.coder_parameter.docker_network_name.value}" ]; then + docker network create "${data.coder_parameter.docker_network_name.value}" --driver=bridge >/dev/null 2>&1 + echo "Created Docker network \`${data.coder_parameter.docker_network_name.value}\`, you can use it with .coder/docker-compose.yml as a external network!" fi - # if ${var.workspace_dir}/.coder exists, then we will run the pre-init scripts + # if ${data.coder_parameter.workspace.value}/.coder exists, then we will run the pre-init scripts # and then the Docker Compose project (if any). - if [ -d "${var.workspace_dir}/.coder" ]; then + if [ -d "${data.coder_parameter.workspace.value}/.coder" ]; then # Run any pre-init scripts in .coder/scripts/pre-init - if [ -d "${var.workspace_dir}/.coder/scripts/pre-init" ]; then - files=$(find "${var.workspace_dir}/.coder/scripts/pre-init" -maxdepth 1 -type f -executable -name '*.sh') + if [ -d "${data.coder_parameter.workspace.value}/.coder/scripts/pre-init" ]; then + files=$(find "${data.coder_parameter.workspace.value}/.coder/scripts/pre-init" -maxdepth 1 -type f -executable -name '*.sh') for f in "$files"; do - (cd "${var.workspace_dir}/.coder" && bash $f) || echo "[coder::preinit] Unable to run pre-init script [$f]" + (cd "${data.coder_parameter.workspace.value}/.coder" && bash $f) || echo "[coder::preinit] Unable to run pre-init script [$f]" done fi # Run the docker compose project - if [ -f "${var.workspace_dir}/.coder/docker-compose.yml" ]; then + if [ -f "${data.coder_parameter.workspace.value}/.coder/docker-compose.yml" ]; then dc="" if command -v docker-compose &>/dev/null; then @@ -153,41 +161,26 @@ resource "coder_agent" "main" { if [ -n "$dc" ]; then echo "[coder::docker-compose] Using \`$dc\` as the Docker compose command!" - $dc -f "${var.workspace_dir}/.coder/docker-compose.yml" up -d + $dc -f "${data.coder_parameter.workspace.value}/.coder/docker-compose.yml" up -d fi fi # run post-init scripts - if [ -d "${var.workspace_dir}/.coder/scripts/post-init" ]; then - files=$(find "${var.workspace_dir}/.coder/scripts/post-init" -maxdepth 1 -type f -executable -name '*.sh') + if [ -d "${data.coder_parameter.workspace.value}/.coder/scripts/post-init" ]; then + files=$(find "${data.coder_parameter.workspace.value}/.coder/scripts/post-init" -maxdepth 1 -type f -executable -name '*.sh') for f in "$files"; do - (cd "${var.workspace_dir}/.coder" && bash $f) || echo "[coder::postinit] Unable to run post-init script [$f]" + (cd "${data.coder_parameter.workspace.value}/.coder" && bash $f) || echo "[coder::postinit] Unable to run post-init script [$f]" done fi fi # initialize dotfiles - ${var.dotfiles_repo != "" ? "coder dotfiles -y ${var.dotfiles_repo}" : ""} + ${data.coder_parameter.dotfiles.value != "" ? "coder dotfiles \"${data.coder_parameter.dotfiles.value}\" -y" : ""} EOL } -resource "coder_app" "code-server" { - count = var.install_codeserver ? 1 : 0 - agent_id = coder_agent.main.id - slug = "code-server" - display_name = "Visual Studio Code" - url = "http://localhost:3621/?folder=${var.workspace_dir}" - icon = "/icon/code.svg" - - healthcheck { - threshold = 10 - interval = 10 - url = "http://localhost:3621/healthz" - } -} - data "docker_registry_image" "image" { - name = var.custom_image != "" ? var.custom_image : "ghcr.io/auguwu/coder-images/${var.base_image}:latest" + name = data.coder_parameter.custom_docker_image.value != "" ? data.coder_parameter.custom_docker_image.value : "ghcr.io/auguwu/coder-images/${data.coder_parameter.base_docker_image.value}" } resource "docker_image" "docker_image" { @@ -208,7 +201,7 @@ resource "docker_container" "workspace" { ] volumes { - container_path = var.home_dir + container_path = data.coder_parameter.volume_dir.value host_path = docker_volume.coder_workspace.mountpoint } diff --git a/template/variables.tf b/template/variables.tf index e8e38a6..4fa0f5d 100644 --- a/template/variables.tf +++ b/template/variables.tf @@ -19,55 +19,110 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -variable "workspace_dir" { - description = "The directory of where your workspace should be cloned." - default = "/home/noel/workspace" - type = string +data "coder_parameter" "workspace" { + description = "Workspace directory to use to where we clone a Git repository to, or a empty directory if `git_url` is not specified." + default = "$HOME/workspace" + mutable = false + type = "string" + name = "Workspace" + icon = "${data.coder_workspace.me.access_url}/icon/folder.svg" } -variable "base_image" { - description = "The base image from Noel's Coder images that should be used." +data "coder_parameter" "volume_dir" { + description = "Directory to persist for the Docker volume" + default = "/home/noel" + mutable = false + type = "string" + name = "Volume Persistence Directory" + icon = "${data.coder_workspace.me.access_url}/icon/folder.svg" +} + +data "coder_parameter" "base_docker_image" { + description = "What base Docker image to use? These are dependent of Noel's Coder images available. Use the `custom_docker_image` option to use a custom one." default = "base" - type = string + mutable = true + icon = "${data.coder_workspace.me.access_url}/icon/docker.png" + name = "Base Docker Image" + type = "string" - validation { - condition = contains(["java", "golang", "base", "node", "rust", "dotnet", ""], var.base_image) - error_message = "Unknown base image to use" + option { + name = "Custom" + value = "" } -} -variable "custom_image" { - description = "The image to use if the base image variable is empty" - default = "" - type = string -} + option { + icon = "${data.coder_workspace.me.access_url}/icon/docker.png" + name = "Base (ghcr.io/auguwu/coder-images/base)" + value = "base" + } -variable "home_dir" { - description = "What directory should be persisted in the Docker volume?" - default = "/home/noel" - type = string + option { + icon = "${data.coder_workspace.me.access_url}/icon/java.svg" + name = "Java (ghcr.io/auguwu/coder-images/java)" + value = "java" + } + + option { + name = "Go (ghcr.io/auguwu/coder-images/golang)" + icon = "https://go.dev/blog/go-brand/Go-Logo/SVG/Go-Logo_Aqua.svg" + value = "golang" + } + + option { + icon = "${data.coder_workspace.me.access_url}/icon/node.svg" + name = "Node.js (ghcr.io/auguwu/coder-images/node)" + value = "node" + } + + option { + icon = "https://raw.githubusercontent.com/dotnet/brand/main/logo/dotnet-logo.svg" + name = ".NET Core (ghcr.io/auguwu/coder-images/dotnet)" + value = "dotnet" + } + + option { + icon = "https://raw.githubusercontent.com/rust-lang/rust-artwork/master/logo/rust-logo-128x128.png" + name = "Rust (ghcr.io/auguwu/coder-images/rust)" + value = "rust" + } } -variable "git_repository" { - description = "Repository URL that is cloned right after the workspace is created" +data "coder_parameter" "custom_docker_image" { + description = "Custom Docker image to use if the custom option was set." + mutable = true default = "" - type = string + type = "string" + name = "Custom Docker Image" + icon = "${data.coder_workspace.me.access_url}/icon/docker.png" + + validation { + error = "Invalid registry image" + + # Grabbed from https://github.com/distribution/distribution/blob/main/reference/regexp.go#L31-L34 + regex = "(^$)|^((?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?)(?::([\\w][\\w.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$" + } } -variable "install_codeserver" { - description = "If the workspace should include code-server to work on this workspace with Visual Studio Code" - default = false - type = bool +data "coder_parameter" "git_repository" { + description = "Git repository URL to clone into the workspace directory. This can be changed if wished." + mutable = true + default = "" + type = "string" + name = "Git Repository" } -variable "dotfiles_repo" { - description = "Repository URL of the dotfiles to initialize" +data "coder_parameter" "dotfiles" { + description = "Git repository URL that holds your files that start with a '.'" + mutable = true default = "" - type = string + type = "string" + name = "Dotfiles" } -variable "docker_network_name" { - description = "Name of the Docker network to use." +data "coder_parameter" "docker_network_name" { + description = "Name for the Docker network you wish to expose. This is useful for .coder/docker-compose.yml to link services between." default = "fluff" - type = string + mutable = false + type = "string" + name = "Docker Network Name" }