Skip to content

Commit 7009490

Browse files
authored
google cloud workstations (#16)
1 parent 8c25079 commit 7009490

File tree

3 files changed

+235
-0
lines changed

3 files changed

+235
-0
lines changed
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: "Workstations"
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '32 7 15 * *' # At 05:32 on day-of-month 15.
7+
8+
jobs:
9+
10+
docker:
11+
name: Build container image for Google Cloud Workstations
12+
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout 🛎️
16+
uses: actions/checkout@v4
17+
- name: Set up Homebrew 🍻
18+
id: set-up-homebrew
19+
uses: Homebrew/actions/setup-homebrew@master
20+
# Install Podman via Homebrew
21+
# https://podman.io/docs/installation#linux-distributions
22+
- name: Install Podman 🦭
23+
run: |
24+
sudo apt-get remove crun podman
25+
brew install crun podman
26+
- name: Versions 💡
27+
run: |
28+
crun --version
29+
podman version
30+
# Login
31+
# https://github.com/marketplace/actions/docker-login
32+
- name: Login to GitHub container registry 🏭
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ghcr.io
36+
username: ${{ github.repository_owner }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Build 🧪
39+
run: |
40+
podman manifest create "cloud-tools-container" && \
41+
podman build \
42+
--network "slirp4netns" \
43+
--manifest "cloud-tools-container" \
44+
--platform "linux/amd64" \
45+
--tag "ghcr.io/cyclenerd/cloud-tools-container:workstations" \
46+
. && \
47+
podman manifest push --all "cloud-tools-container" "docker://ghcr.io/cyclenerd/cloud-tools-container:workstations"

workstations/Dockerfile

+184
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Copyright 2024 Nils Knieling. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Cloud Workstations base editor, Code OSS for Cloud Workstations, based on Code-OSS
16+
# https://cloud.google.com/workstations/docs/preconfigured-base-images
17+
FROM us-central1-docker.pkg.dev/cloud-workstations-images/predefined/code-oss:latest
18+
19+
# https://github.com/GoogleCloudPlatform/gcr-cleaner/releases
20+
ENV GCR_CLEANER_VERSION="0.12.0"
21+
# https://github.com/sgarciac/fuego/releases
22+
ENV FUEGO_VERSION="0.34.0"
23+
ENV FUEGO_URL="https://github.com/sgarciac/fuego/archive/refs/tags/${FUEGO_VERSION}.tar.gz"
24+
# https://github.com/terraform-docs/terraform-docs/releases
25+
ENV TFDOC_VERSION="0.17.0"
26+
# https://github.com/aquasecurity/tfsec/releases
27+
ENV TFSEC_VERSION="1.28.6"
28+
# https://github.com/terraform-linters/tflint/releases
29+
ENV TFLINT_VERSION="0.51.1"
30+
# Default to UTF-8 file.encoding
31+
ENV LANG="C.UTF-8"
32+
# Set debconf frontend to noninteractive
33+
ENV DEBIAN_FRONTEND="noninteractive"
34+
35+
# Download URLs for AMD64 (X86/64)
36+
ENV AWS_CLI_URL="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
37+
ENV GCR_CLEANER_URL="https://github.com/GoogleCloudPlatform/gcr-cleaner/releases/download/v${GCR_CLEANER_VERSION}/gcr-cleaner-cli_${GCR_CLEANER_VERSION}_linux_amd64.tar.gz"
38+
ENV OPA_URL="https://github.com/open-policy-agent/opa/releases/latest/download/opa_linux_amd64_static"
39+
ENV TERRAGRUNT_URL="https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_amd64"
40+
ENV TFDOC_URL="https://github.com/terraform-docs/terraform-docs/releases/download/v${TFDOC_VERSION}/terraform-docs-v${TFDOC_VERSION}-linux-amd64.tar.gz"
41+
ENV TFLINT_URL="https://github.com/terraform-linters/tflint/releases/download/v${TFLINT_VERSION}/tflint_linux_amd64.zip"
42+
ENV TFSEC_URL="https://github.com/aquasecurity/tfsec/releases/download/v${TFSEC_VERSION}/tfsec_${TFSEC_VERSION}_linux_amd64.tar.gz"
43+
44+
# Install tools
45+
RUN uname -m && \
46+
apt-get update -yq && \
47+
apt-get install -yqq \
48+
apt-transport-https \
49+
apt-utils \
50+
build-essential \
51+
ca-certificates \
52+
cpanminus \
53+
curl \
54+
dnsutils \
55+
figlet \
56+
git \
57+
golang-go \
58+
gpg \
59+
htop \
60+
jq \
61+
lsb-release \
62+
mutt \
63+
python3-pip \
64+
shellcheck \
65+
skopeo \
66+
software-properties-common \
67+
tar \
68+
unzip \
69+
zip && \
70+
# Add Hashicorp repository
71+
curl -fsSL "https://apt.releases.hashicorp.com/gpg" | gpg --dearmor -o "/usr/share/keyrings/releases-hashicorp.gpg" && \
72+
echo "deb [signed-by=/usr/share/keyrings/releases-hashicorp.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee -a "/etc/apt/sources.list.d/releases-hashicorp.list" && \
73+
# Add Ansible PPA repository
74+
add-apt-repository "ppa:ansible/ansible" && \
75+
# Install tools
76+
apt-get update -yq && \
77+
apt-get install -yqq \
78+
google-cloud-cli \
79+
google-cloud-sdk-gke-gcloud-auth-plugin \
80+
terraform \
81+
packer \
82+
vault \
83+
sentinel \
84+
ansible \
85+
kubectl \
86+
helm && \
87+
# Fix "vault: Operation not permitted" error
88+
# https://github.com/hashicorp/vault/issues/10924
89+
setcap -r "/usr/bin/vault" && \
90+
# AWS CLI (https://github.com/GoogleCloudPlatform/gcr-cleaner)
91+
echo "AWS CLI URL: '$AWS_CLI_URL'" && \
92+
curl -L "$AWS_CLI_URL" -o "awscliv2.zip" && \
93+
unzip -qq "awscliv2.zip" && \
94+
./aws/install -b "/usr/local/bin" -i "/usr/local/aws-cli" && \
95+
rm -rf aws* && \
96+
# GCR Cleaner (https://github.com/GoogleCloudPlatform/gcr-cleaner)
97+
curl -L "$GCR_CLEANER_URL" -o "gcr-cleaner-cli.tar.gz" && \
98+
tar -xf "gcr-cleaner-cli.tar.gz" "gcr-cleaner-cli" && \
99+
mv "gcr-cleaner-cli" "/usr/bin/gcr-cleaner-cli" && \
100+
rm "gcr-cleaner-cli.tar.gz" && \
101+
# Fuego (https://github.com/sgarciac/fuego)
102+
curl -L "$FUEGO_URL" -o "fuego.tar.gz" && \
103+
tar -xf "fuego.tar.gz" && \
104+
cd "fuego-${FUEGO_VERSION}" && \
105+
go build && \
106+
mv "fuego" "/usr/bin/fuego" && \
107+
cd "../" && \
108+
rm -rf fuego* && \
109+
# terraform-docs (https://github.com/terraform-docs/terraform-docs)
110+
curl -L "$TFDOC_URL" -o "terraform-docs.tar.gz" && \
111+
tar -xf "terraform-docs.tar.gz" "terraform-docs" && \
112+
mv "terraform-docs" "/usr/bin/terraform-docs" && \
113+
rm "terraform-docs.tar.gz" && \
114+
# tfsec (https://github.com/aquasecurity/tfsec)
115+
curl -L "$TFSEC_URL" -o "tfsec.tar.gz" && \
116+
tar -xf "tfsec.tar.gz" "tfsec" && \
117+
mv "tfsec" "/usr/bin/tfsec" && \
118+
rm "tfsec.tar.gz" && \
119+
# tflint (https://github.com/terraform-linters/tflint)
120+
curl -L "$TFLINT_URL" -o "tflint.zip" && \
121+
unzip -qq "tflint.zip" && \
122+
chmod +x "tflint" && \
123+
mv "tflint" "/usr/bin/tflint" && \
124+
rm "tflint.zip" && \
125+
# Terragrunt (https://terragrunt.gruntwork.io/)
126+
curl -L "$TERRAGRUNT_URL" -o "terragrunt" && \
127+
chmod +x "terragrunt" && \
128+
mv "terragrunt" "/usr/bin/terragrunt" && \
129+
# Open Policy Agent (https://www.openpolicyagent.org/)
130+
curl -L "$OPA_URL" -o "opa" && \
131+
chmod +x "opa" && \
132+
mv "opa" "/usr/bin/opa" && \
133+
# Delete caches
134+
apt-get clean && \
135+
rm -rf /var/lib/apt/lists/* && \
136+
pip3 cache purge && \
137+
go clean -cache && \
138+
go clean -modcache && \
139+
go clean -testcache && \
140+
go clean -fuzzcache && \
141+
# Disable Python virtual environments warning
142+
rm "/usr/lib/python3.12/EXTERNALLY-MANAGED" && \
143+
# Basic smoke test
144+
ansible --version && \
145+
ansible-playbook --version && \
146+
aws --version && \
147+
bash --version && \
148+
cpanm --version && \
149+
curl --version && \
150+
dig -v && \
151+
figlet -v && \
152+
fuego --version && \
153+
gcloud --version && \
154+
gcr-cleaner-cli -version && \
155+
git --version && \
156+
go version && \
157+
helm version && \
158+
kubectl help && \
159+
lsb_release -a && \
160+
mutt -v && \
161+
opa version && \
162+
openssl version && \
163+
packer --version && \
164+
perl --version && \
165+
pip3 --version && \
166+
python3 --version && \
167+
sentinel --version && \
168+
shellcheck --version && \
169+
skopeo -v && \
170+
ssh -V && \
171+
tar --version && \
172+
terraform --version && \
173+
terraform-docs --version && \
174+
terragrunt --version && \
175+
tflint --version && \
176+
tfsec --version && \
177+
unzip -v && \
178+
vault --version && \
179+
zip -v
180+
181+
# If you're reading this and have any feedback on how this image could be
182+
# improved, please open an issue or a pull request so we can discuss it!
183+
#
184+
# https://github.com/Cyclenerd/cloud-tools-container

workstations/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Cloud Workstations Container
2+
3+
Optimized for Google Cloud Workstations.
4+
Based on [Cloud Workstations base image](https://cloud.google.com/workstations/docs/preconfigured-base-images).

0 commit comments

Comments
 (0)