Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit f0c59b3

Browse files
committed
[2023.05.14] Update all software and use Coder parameters instead of Terraform values
1 parent 18fb49b commit f0c59b3

File tree

10 files changed

+158
-109
lines changed

10 files changed

+158
-109
lines changed

images/base/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ RUN usermod -aG docker ${USERNAME}
5959

6060
# stuff here
6161
ENV BAZEL_BUILDTOOLS_VERSION="6.1.2"
62-
ENV GITHUB_CLI_VERSION="2.28.0"
63-
ENV CODER_CLI_VERSION="0.23.0"
62+
ENV GITHUB_CLI_VERSION="2.29.0"
63+
ENV CODER_CLI_VERSION="0.23.2"
6464
ENV TERRAFORM_VERSION="1.4.6"
6565
ENV BAZELISK_VERSION="1.16.0"
6666
ENV KUBECTL_VERSION="1.27.1"
67-
ENV HELM_VERSION="3.11.3"
67+
ENV HELM_VERSION="3.12.0"
6868

6969
# Get current architecture and download software here
7070
# also this looks like shit, i know!

images/base/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ This image is the main base for all of the images in this repository.
55
| Name | Description | Version |
66
| ---------------- | --------------------------------------------------------------------------------- | -------------------------- |
77
| Bazel Buildtools | A bazel BUILD file formatter and editor | [v6.1.2][bazel-buildtools] |
8-
| GitHub CLI | GitHub's official command line utility | [v2.28.0][github-cli] |
9-
| Coder (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.23.0][coder] |
8+
| GitHub CLI | GitHub's official command line utility | [v2.29.0][github-cli] |
9+
| Coder (OSS) | Remote development environments on your infrastructure provisioned with Terraform | [v0.23.2][coder] |
1010
| Terraform | Automate Infrastructure on Any Cloud | [v1.4.6][terraform] |
1111
| Bazelisk | A user-friendly launcher for Bazel. | [v1.16.0][bazelisk] |
1212
| `kubectl` | kubectl controls the Kubernetes cluster manager. | [v1.27.1][kubectl] |
13-
| `bazel` | a fast, scalable, multi-language and extensible build system | [v6.1.2][bazel] |
14-
| `helm` | The Kubernetes Package Manager | [v3.11.3][helm] |
13+
| `bazel` | a fast, scalable, multi-language and extensible build system | [v6.2.0][bazel] |
14+
| `helm` | The Kubernetes Package Manager | [v3.12.0][helm] |
1515

16-
[bazel-buildtools]: https://github.com/bazelbuild/buildtools/releases/tag/6.1.2
17-
[github-cli]: https://github.com/cli/cli/releases/tag/v2.28.0
16+
[bazel-buildtools]: https://github.com/bazelbuild/buildtools/releases/tag/v6.1.2
17+
[github-cli]: https://github.com/cli/cli/releases/tag/v2.29.0
1818
[terraform]: https://github.com/hashicorp/terraform/releases/tag/v1.4.6
1919
[bazelisk]: https://github.com/bazelbuild/bazelisk/releases/tag/v1.16.0
2020
[kubectl]: https://github.com/kubernetes/kubernetes/releases/tag/v1.27.1
21-
[coder]: https://github.com/coder/coder/releases/tag/v0.23.0
22-
[bazel]: https://github.com/bazelbuild/bazel/releases/tag/6.1.2
23-
[helm]: https://github.com/helm/helm/releases/tag/v3.11.3
21+
[coder]: https://github.com/coder/coder/releases/tag/v0.23.2
22+
[bazel]: https://github.com/bazelbuild/bazel/releases/tag/6.2.0
23+
[helm]: https://github.com/helm/helm/releases/tag/v3.12.0
2424

2525
### Helm
2626
Helm comes with Bitnami's charts library preconfigured.

images/golang/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ ENV USERNAME=noel
2727
USER root
2828

2929
# Put versions in environment variables
30-
ENV GOLANG_VERSION="1.20.3"
31-
ENV GORELEASER_VERSION="1.17.2"
30+
ENV GOLANG_VERSION="1.20.4"
31+
ENV GORELEASER_VERSION="1.18.2"
3232
ENV GOLANGCI_VERSION="1.52.2"
3333

3434
# Install packages here.

images/golang/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ This is the Docker image that bundles the Go compiler with **goreleaser** and **
44
## Bundled Software
55
| Name | Description | Version |
66
| ---------- | -------------------------------------------------- | --------------------- |
7-
| Go | The Go programming language | [v1.20.3][golang] |
8-
| GoReleaser | Deliver Go binaries as fast and easily as possible | [v1.17.2][goreleaser] |
7+
| Go | The Go programming language | [v1.20.4][golang] |
8+
| GoReleaser | Deliver Go binaries as fast and easily as possible | [v1.18.2][goreleaser] |
99
| Golang CI | Fast linters Runner for Go | [v1.52.2][golangci] |
1010

11-
[goreleaser]: https://github.com/goreleaser/goreleaser/releases/tag/v1.17.2
11+
[goreleaser]: https://github.com/goreleaser/goreleaser/releases/tag/v1.18.2
1212
[golangci]: https://github.com/golangci/golangci-lint/releases/tag/v1.52.2
13-
[golang]: https://github.com/golang/go/releases/tag/go1.20.3
13+
[golang]: https://github.com/golang/go/releases/tag/go1.20.4

images/java/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
# SOFTWARE.
2121

22-
# use April 26th image (since Adoptium doesn't support Ubuntu Lunar yet)
23-
FROM ghcr.io/auguwu/coder-images/base:2023.04.26
22+
FROM ghcr.io/auguwu/coder-images/base
2423

2524
ENV USERNAME=noel
2625

@@ -29,14 +28,16 @@ USER root
2928

3029
# Set version environment variables
3130
ENV GRADLE_VERSION="8.1.1"
32-
ENV MAVEN_VERSION="3.9.1"
31+
ENV MAVEN_VERSION="3.9.2"
3332

3433
# install required things
3534
RUN DEBIAN_FRONTEND="noninteractive" apt install -y wget libarchive-tools
3635

37-
# Install Temurin 19
36+
# Install Temurin JDK 20
3837
RUN wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add -
39-
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
38+
39+
# force it to use the Kinetic repository until it supports 23.04
40+
RUN echo "deb https://packages.adoptium.net/artifactory/deb kinetic main" | sudo tee /etc/apt/sources.list.d/adoptium.list
4041
RUN DEBIAN_FRONTEND="noninteractive" apt update && \
4142
DEBIAN_FRONTEND="noninteractive" apt install -y temurin-20-jdk
4243

images/java/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This image extends the [base image](https://github.com/auguwu/coder-images/pkgs/
66
| ------ | --------------------------------------------------- | ------------------------------- |
77
| JDK | The Java development kit. | [jdk-20.0.1+9][temurin-release] |
88
| Gradle | Adaptable, fast automation for all | [v8.1.1][gradle-release] |
9-
| Maven | Software project management and comprehension tool. | [v3.9.1][maven-release] |
9+
| Maven | Software project management and comprehension tool. | [v3.9.2][maven-release] |
1010

1111
[temurin-release]: https://github.com/adoptium/temurin20-binaries/releases/tag/jdk-20.0.1%2B9
1212
[gradle-release]: https://github.com/gradle/gradle/releases/tag/v8.1.1
13-
[maven-release]: https://github.com/apache/maven/releases/tag/maven-3.9.1
13+
[maven-release]: https://github.com/apache/maven/releases/tag/maven-3.9.2

images/node/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ENV USERNAME=noel
2727
USER root
2828

2929
# versions here
30-
ENV NODE_VERSION="20.0.0"
30+
ENV NODE_VERSION="20.1.0"
3131

3232
# Install xz-utils so we can unpack the Node.js installation
3333
RUN DEBIAN_FRONTEND="noninteractive" apt install -y xz-utils

images/node/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ This image extends from the [base image](https://github.com/auguwu/coder-images/
44
## Bundled Software
55
| Name | Description | Version |
66
| ------- | ----------------------------------- | ---------------- |
7-
| Node.js | Node.js JavaScript runtime ✨🐢🚀✨ | [v20.0.0][node] |
7+
| Node.js | Node.js JavaScript runtime ✨🐢🚀✨ | [v20.1.0][node] |
88

9-
[node]: https://github.com/nodejs/node/releases/v20.0.0
9+
[node]: https://github.com/nodejs/node/releases/v20.1.0

template/main.tf

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,39 @@ data "coder_workspace" "me" {
4646

4747
resource "coder_agent" "main" {
4848
arch = "amd64"
49-
dir = var.home_dir
49+
dir = data.coder_parameter.volume_dir.value
5050
os = "linux"
5151

5252
metadata {
5353
display_name = "Processes"
54-
key = "proc_count"
54+
interval = 1
55+
timeout = 1
5556
script = "ps aux | wc -l"
57+
key = "proc_count"
58+
}
59+
60+
metadata {
61+
display_name = "CPU Usage"
5662
interval = 1
5763
timeout = 1
64+
script = "vmstat | awk 'FNR==3 {printf \"%2.0f%%\", $13+14+16}'"
65+
key = "cpu"
5866
}
5967

6068
metadata {
6169
display_name = "Load Average"
62-
key = "load"
63-
script = "awk '{print $1}' /proc/loadavg"
6470
interval = 1
6571
timeout = 1
72+
script = "awk '{print $1}' /proc/loadavg"
73+
key = "load"
6674
}
6775

6876
metadata {
6977
display_name = "Disk Usage"
70-
key = "disk"
71-
script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'"
7278
interval = 1
7379
timeout = 1
80+
script = "df -h | awk '$6 ~ /^\\/$/ { print $5 }'"
81+
key = "disk"
7482
}
7583

7684
metadata {
@@ -81,10 +89,18 @@ resource "coder_agent" "main" {
8189
key = "containers"
8290
}
8391

92+
metadata {
93+
display_name = "Memory Usage"
94+
interval = 1
95+
timeout = 1
96+
script = "free | awk '/^Mem/ { printf(\"%.0f%%\", $4/$2 * 100.0) }'"
97+
key = "memory"
98+
}
99+
84100
startup_script = <<-EOL
85101
#!/bin/bash
86102
# Fix folder permissions since root owns /home/noel for some reason???
87-
sudo chown -R noel:noel /home/noel
103+
sudo chown -R $USER:$USER /home/$USER
88104
89105
if [ ! -f ~/.profile ]; then
90106
cp /etc/skel/.profile $HOME/.profile
@@ -110,37 +126,29 @@ resource "coder_agent" "main" {
110126
sleep 1
111127
done
112128
113-
# Install code-server if enabled
114-
${var.install_codeserver == true ? "curl -fsSL https://code-server.dev/install.sh | sh" : ""}
115-
${var.install_codeserver == true ? "code-server --auth none --port 3621 > /dev/null 2>&1 &" : ""}
116-
117129
# Clone the given repository if needed
118-
if ! [ -d "${var.workspace_dir}" ]; then
119-
${var.git_repository != "" ? "git clone ${var.git_repository} ${var.workspace_dir}" : ""}
120-
fi
121-
122-
if ! [ -d "${var.workspace_dir}" ]; then
123-
mkdir ${var.workspace_dir}
130+
if ! [ -d "${data.coder_parameter.workspace.value}" ]; then
131+
${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}"}
124132
fi
125133
126-
if [ -n "${var.docker_network_name}" ]; then
127-
docker network create "${var.docker_network_name}" --driver=bridge >/dev/null 2>&1
128-
echo "Created Docker network \`${var.docker_network_name}\`, you can use it with .coder/docker-compose.yml as a external network!"
134+
if [ -n "${data.coder_parameter.docker_network_name.value}" ]; then
135+
docker network create "${data.coder_parameter.docker_network_name.value}" --driver=bridge >/dev/null 2>&1
136+
echo "Created Docker network \`${data.coder_parameter.docker_network_name.value}\`, you can use it with .coder/docker-compose.yml as a external network!"
129137
fi
130138
131-
# if ${var.workspace_dir}/.coder exists, then we will run the pre-init scripts
139+
# if ${data.coder_parameter.workspace.value}/.coder exists, then we will run the pre-init scripts
132140
# and then the Docker Compose project (if any).
133-
if [ -d "${var.workspace_dir}/.coder" ]; then
141+
if [ -d "${data.coder_parameter.workspace.value}/.coder" ]; then
134142
# Run any pre-init scripts in .coder/scripts/pre-init
135-
if [ -d "${var.workspace_dir}/.coder/scripts/pre-init" ]; then
136-
files=$(find "${var.workspace_dir}/.coder/scripts/pre-init" -maxdepth 1 -type f -executable -name '*.sh')
143+
if [ -d "${data.coder_parameter.workspace.value}/.coder/scripts/pre-init" ]; then
144+
files=$(find "${data.coder_parameter.workspace.value}/.coder/scripts/pre-init" -maxdepth 1 -type f -executable -name '*.sh')
137145
for f in "$files"; do
138-
(cd "${var.workspace_dir}/.coder" && bash $f) || echo "[coder::preinit] Unable to run pre-init script [$f]"
146+
(cd "${data.coder_parameter.workspace.value}/.coder" && bash $f) || echo "[coder::preinit] Unable to run pre-init script [$f]"
139147
done
140148
fi
141149
142150
# Run the docker compose project
143-
if [ -f "${var.workspace_dir}/.coder/docker-compose.yml" ]; then
151+
if [ -f "${data.coder_parameter.workspace.value}/.coder/docker-compose.yml" ]; then
144152
dc=""
145153
146154
if command -v docker-compose &>/dev/null; then
@@ -153,41 +161,26 @@ resource "coder_agent" "main" {
153161
154162
if [ -n "$dc" ]; then
155163
echo "[coder::docker-compose] Using \`$dc\` as the Docker compose command!"
156-
$dc -f "${var.workspace_dir}/.coder/docker-compose.yml" up -d
164+
$dc -f "${data.coder_parameter.workspace.value}/.coder/docker-compose.yml" up -d
157165
fi
158166
fi
159167
160168
# run post-init scripts
161-
if [ -d "${var.workspace_dir}/.coder/scripts/post-init" ]; then
162-
files=$(find "${var.workspace_dir}/.coder/scripts/post-init" -maxdepth 1 -type f -executable -name '*.sh')
169+
if [ -d "${data.coder_parameter.workspace.value}/.coder/scripts/post-init" ]; then
170+
files=$(find "${data.coder_parameter.workspace.value}/.coder/scripts/post-init" -maxdepth 1 -type f -executable -name '*.sh')
163171
for f in "$files"; do
164-
(cd "${var.workspace_dir}/.coder" && bash $f) || echo "[coder::postinit] Unable to run post-init script [$f]"
172+
(cd "${data.coder_parameter.workspace.value}/.coder" && bash $f) || echo "[coder::postinit] Unable to run post-init script [$f]"
165173
done
166174
fi
167175
fi
168176
169177
# initialize dotfiles
170-
${var.dotfiles_repo != "" ? "coder dotfiles -y ${var.dotfiles_repo}" : ""}
178+
${data.coder_parameter.dotfiles.value != "" ? "coder dotfiles \"${data.coder_parameter.dotfiles.value}\" -y" : ""}
171179
EOL
172180
}
173181

174-
resource "coder_app" "code-server" {
175-
count = var.install_codeserver ? 1 : 0
176-
agent_id = coder_agent.main.id
177-
slug = "code-server"
178-
display_name = "Visual Studio Code"
179-
url = "http://localhost:3621/?folder=${var.workspace_dir}"
180-
icon = "/icon/code.svg"
181-
182-
healthcheck {
183-
threshold = 10
184-
interval = 10
185-
url = "http://localhost:3621/healthz"
186-
}
187-
}
188-
189182
data "docker_registry_image" "image" {
190-
name = var.custom_image != "" ? var.custom_image : "ghcr.io/auguwu/coder-images/${var.base_image}:latest"
183+
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}"
191184
}
192185

193186
resource "docker_image" "docker_image" {
@@ -208,7 +201,7 @@ resource "docker_container" "workspace" {
208201
]
209202

210203
volumes {
211-
container_path = var.home_dir
204+
container_path = data.coder_parameter.volume_dir.value
212205
host_path = docker_volume.coder_workspace.mountpoint
213206
}
214207

0 commit comments

Comments
 (0)