Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 5155710

Browse files
committed
Initial commit
0 parents  commit 5155710

10 files changed

Lines changed: 404 additions & 0 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gitignore

.github/workflows/release.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# coder-templates: Templates to aid development with Noelware's Charts Platform with Coder (https://coder.com)
2+
# Copyright (c) 2022 Noelware <team@noelware.org>
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
name: Release Docker image version
23+
on:
24+
release:
25+
types: [released]
26+
jobs:
27+
release:
28+
name: Docker Image version
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v3
33+
34+
- name: Setup Docker Buildx
35+
uses: docker/setup-buildx-action@v2
36+
37+
- name: Login into GitHub Container Registry
38+
uses: docker/login-action@v2
39+
with:
40+
registry: registry.floofy.dev
41+
username: august
42+
password: ${{ secrets.REGISTRY_PASSWORD }}
43+
44+
- name: Build and push
45+
uses: docker/build-push-action@v3
46+
with:
47+
context: images/base
48+
file: ./images/base/Dockerfile
49+
platforms: linux/amd64
50+
push: true
51+
tags: registry.floofy.dev/noelware/charted/coder:latest

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Created by https://www.toptal.com/developers/gitignore/api/Terraform
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=Terraform
3+
4+
### Terraform ###
5+
# Local .terraform directories
6+
**/.terraform/*
7+
8+
# .tfstate files
9+
*.tfstate
10+
*.tfstate.*
11+
12+
# Crash log files
13+
crash.log
14+
crash.*.log
15+
16+
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
17+
# password, private keys, and other secrets. These should not be part of version
18+
# control as they are data points which are potentially sensitive and subject
19+
# to change depending on the environment.
20+
*.tfvars
21+
*.tfvars.json
22+
23+
# Ignore override files as they are usually used to override resources locally and so
24+
# are not checked in
25+
override.tf
26+
override.tf.json
27+
*_override.tf
28+
*_override.tf.json
29+
30+
# Include override files you do wish to add to version control using negated pattern
31+
# !example_override.tf
32+
33+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
34+
# example: *tfplan*
35+
36+
# Ignore CLI configuration files
37+
.terraformrc
38+
terraform.rc
39+
40+
# End of https://www.toptal.com/developers/gitignore/api/Terraform

.terraform.lock.hcl

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"editor.tabSize": 2,
3+
"[terraform]": {
4+
"editor.defaultFormatter": "hashicorp.terraform"
5+
},
6+
"[terraform-vars]": {
7+
"editor.defaultFormatter": "hashicorp.terraform"
8+
}
9+
}

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# coder-templates: Templates to aid development with Noelware's Charts Platform with Coder (https://coder.com)
2+
# Copyright (c) 2022 Noelware <team@noelware.org>
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
# We only need this since charted-server requires a Go installation, so... yeah!
23+
FROM ghcr.io/auguwu/coder-images/java
24+
25+
COPY --from=ghcr.io/auguwu/coder-images/golang /opt/golang/tools/golangci /opt/golang/tools/golangci
26+
COPY --from=ghcr.io/auguwu/coder-images/golang /opt/golang/go /opt/golang/go
27+
28+
ENV PATH=$PATH:/opt/golang/go/bin:/opt/golang/tools/golangci

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Noelware <team@noelware.org>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Coder Templates for Noelware's Charts Platform
2+
> *Templates to aid development with Noelware's Charts Platform with [Coder](https://coder.com)*
3+
4+
This repository is meant to provide templates to help aid development of [charted-server](https://charts.noelware.org) on Coder, which [Noel](https://floofy.dev) uses for remote development.
5+
6+
## Auto-import template
7+
```sh
8+
$ git clone https://github.com/charted-dev/coder-templates && cd coder-templates
9+
$ coder template create charted-server --url=<coder deployment url>
10+
```
11+
12+
## License
13+
**coder-templates** is released under the **MIT License** with love by Noelware. <3

main.tf

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# coder-templates: Templates to aid development with Noelware's Charts Platform with Coder (https://coder.com)
2+
# Copyright (c) 2022 Noelware <team@noelware.org>
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
terraform {
23+
required_providers {
24+
coder = {
25+
source = "coder/coder"
26+
version = "0.6.5"
27+
}
28+
29+
kubernetes = {
30+
source = "hashicorp/kubernetes"
31+
version = "2.16.1"
32+
}
33+
}
34+
}
35+
36+
provider "kubernetes" {
37+
config_path = var.use_host_kubeconfig == true ? "~/.kube/config" : null
38+
config_context = try(var.kube_context, "") != "" ? var.kube_context : null
39+
}
40+
41+
data "coder_workspace" "me" {
42+
}
43+
44+
resource "coder_agent" "main" {
45+
arch = "amd64"
46+
dir = var.dir
47+
os = "linux"
48+
49+
startup_script = <<-EOF
50+
#!/bin/bash
51+
52+
# Install Docker on the container, since we need the client to connect to the
53+
# privileged pod.
54+
sudo apt update
55+
sudo apt install ca-certificates curl gnupg lsb-release
56+
57+
sudo mkdir -p /etc/apt/keyrings
58+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
59+
60+
sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin
61+
sudo systemctl enable --now docker
62+
63+
sudo usermod -aG docker $USER
64+
65+
# Now, let's enable dotfiles
66+
${var.dotfiles_repo != "" ? "coder dotfiles -y ${var.dotfiles_repo}" : ""}
67+
git clone https://github.com/charted-dev/charted /home/noel/workspace
68+
EOF
69+
}
70+
71+
resource "kubernetes_persistent_volume_claim" "charted-workspace" {
72+
metadata {
73+
namespace = var.namespace
74+
name = "charted-server-workspace"
75+
}
76+
77+
wait_until_bound = false
78+
spec {
79+
access_modes = ["ReadWriteMany"]
80+
resources {
81+
requests = {
82+
storage = "20Gi"
83+
}
84+
}
85+
}
86+
}
87+
88+
resource "kubernetes_pod" "charted-server" {
89+
metadata {
90+
namespace = var.namespace
91+
name = "charted-server"
92+
93+
labels = {
94+
"k8s.noelware.cloud/component" = "cloud",
95+
"k8s.noelware.cloud/template" = "charted-dev/coder-templates"
96+
}
97+
}
98+
99+
spec {
100+
security_context {
101+
run_as_user = "1000"
102+
fs_group = "1000"
103+
}
104+
105+
container {
106+
name = "charted-server"
107+
image = var.docker_image
108+
command = ["/bin/bash", "-c", coder_agent.main.init_script]
109+
image_pull_policy = "Always"
110+
111+
env {
112+
name = "CODER_ACCESS_URL"
113+
value = "https://coder.floofy.dev"
114+
}
115+
116+
env {
117+
name = "CODER_AGENT_TOKEN"
118+
value = coder_agent.main.token
119+
}
120+
121+
volume_mount {
122+
mount_path = "/home/noel"
123+
read_only = false
124+
name = "workspace"
125+
}
126+
127+
security_context {
128+
run_as_user = "1000"
129+
}
130+
}
131+
132+
volume {
133+
name = "workspace"
134+
persistent_volume_claim {
135+
claim_name = "charted-workspace"
136+
read_only = false
137+
}
138+
}
139+
}
140+
}

0 commit comments

Comments
 (0)