Skip to content

Commit

Permalink
Reorganize Documentation For a Better Learning Journey (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman authored Jun 25, 2024
1 parent ff192f3 commit b53d696
Show file tree
Hide file tree
Showing 503 changed files with 16,275 additions and 7,915 deletions.
51 changes: 51 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM golang:1.22 AS confetty

# Set the working directory
WORKDIR /app

# Install the confetty application
RUN go install github.com/maaslalani/confetty@latest

FROM mcr.microsoft.com/vscode/devcontainers/base:debian

# Copy the binary from the builder stage
COPY --from=confetty /go/bin/confetty /usr/local/bin/confetty

# Install Docker CLI and Docker Compose plugin
RUN apt-get update && \
apt-get install -y ca-certificates curl gnupg lsb-release apt-utils direnv screen && \
mkdir -p /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin && \
rm -rf /var/lib/apt/lists/*

# Ensure the vscode user can access the Docker socket, and change the shell to zsh
RUN usermod -aG docker vscode && \
chsh -s /bin/zsh vscode

# Install the starship prompt
RUN curl -sS https://starship.rs/install.sh | sh -s -- -y

# Install OpenTofu
RUN curl -1sSLf 'https://get.opentofu.org/install-opentofu.sh' | bash -s -- --root-method none --install-method deb

# Install Kustomize binary (required by Helmfile)
RUN curl -1sSLf "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- /usr/local/bin

# Install the cloudposse Debian repository
RUN curl -1sLf 'https://dl.cloudsmith.io/public/cloudposse/packages/cfg/setup/bash.deb.sh' | bash

RUN apt-get -y install atmos terraform kubectl helmfile helm k9s stern && \
su - vscode -c "helm plugin install https://github.com/databus23/helm-diff"

# Install the rootfs/ configurations
COPY rootfs/ /

# Direnv permissions
RUN chown -R vscode:vscode /home/vscode/.config && \
chmod -R 755 /home/vscode/.config && \
chmod 644 /home/vscode/.config/direnv/direnvrc
80 changes: 80 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "Atmos Demo Lab",
"forwardPorts": [80, 443],
"portsAttributes": {
"80": {
"label": "Kubernetes Ingress"
},
"443": {
"label": "Kubernetes Ingress (TLS)"
}
},
"security.workspace.trust.emptyWindow": true,
"security.workspace.trust.untrustedFiles": "prompt",
"security.workspace.trust.domain": {
"*.github.com": true,
"*.app.github.dev": true,
"localhost": true
},
"build": {
"dockerfile": "Dockerfile",
"context": "."
},
"hostRequirements": {
"cpus": 8,
"memory": "16gb",
"storage": "32gb"
},
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"],
"postCreateCommand": "/workspace/.devcontainer/post-create.sh",
"service": "localstack",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker": {},
/*"ghcr.io/devcontainers/features/go:1": {
"version": "1.22"
},*/
},
"workspaceFolder": "/workspace/examples",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",

"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"bierner.github-markdown-preview",
"tomasdahlqvist.markdown-admonitions",
"HashiCorp.terraform",
"redhat.vscode-yaml",
"casualjim.gotemplate",
"EditorConfig.EditorConfig"
],
"settings": {
"git.openRepositoryInParentFolders": "always",
"git.autofetch": true,
"git.showProgress": true,
"workbench.startupEditor": "readme",
"workbench.editor.autoLockGroups": {
"readme": "/welcome.md"
},
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
},
"terminal.integrated.tabs.title": "Atmos (${process})",
"terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}",
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.allowWorkspaceConfiguration": true,
"terminal.integrated.commandsToSkipShell": [],
"yaml.schemaStore.enable": true,
"json.schemas": [
],
"yaml.schemas": {
"https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json": [
"**/stacks/**/*.yaml",
"!**/stacks/workflows/**/*.yaml",
"!**/stacks/schemas/**/*.yaml"
]
}
}
}
}
}
28 changes: 28 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/zsh

# Let's not show what commands the script is running
set +x

# Display a different welcome message for Codespaces
mv /workspace/examples/welcome.md /workspace/examples/README.md

# Use screen to run the following commands in the background so they don’t block startup time
# Note that this also means errors won’t fail the bootstrapping of the container, which can mask issues.

# Install a .envrc file in each example directory (it's ignored in .gitignore)
screen -L -Logfile /tmp/direnv.log -S direnv-setup -dm \
sh -c "find /workspace/examples -mindepth 1 -type d -exec sh -c 'echo show_readme > {}/.envrc' \;"

# Start localstack in the background, since it can take a little bit to start up
cd /workspace/examples/demo-localstack
screen -L -Logfile /tmp/localstack.log -S localstack -dm sh -c 'docker compose up'

# Start k3s in the background, since it can take a little bit to start up
# Note, it will mount . to the container and write the kubeconfig.yaml file
# This should used as the file for KUBECONFIG
cd /workspace/examples/demo-helmfile
screen -L -Logfile /tmp/k3s.log -S k3s -dm sh -c 'docker compose up'

# Since we cannot mount volumes inside of compose, we need to copy the kubeconfig.yaml file to the workspace
export KUBECONFIG=${KUBECONFIG:-/workspace/examples/demo-helmfile/kubeconfig.yaml}
screen -L -Logfile /tmp/kubeconfig.log -S kubeconfig -dm sh -c 'until test -f ${KUBECONFIG}; do docker cp demo-helmfile-server-1:/output/kubeconfig.yaml ${KUBECONFIG}; sleep 1; done; chmod 600 ${KUBECONFIG}'
11 changes: 11 additions & 0 deletions .devcontainer/rootfs/home/vscode/.config/direnv/direnvrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
show_readme() {
if [ -f "./README.md" ]; then
# Check if the README.md file has been touched in the last 60 seconds
last_modified=$(stat -c %Y "./README.md")
current_time=$(date +%s)
if [ $((current_time - last_modified)) -gt 60 ]; then
code "./README.md"
touch "./README.md"
fi
fi
}
48 changes: 48 additions & 0 deletions .devcontainer/rootfs/home/vscode/.config/starship.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_state\
$git_status\
$cmd_duration\
$line_break\
$python\
$character"""

command_timeout = 2000

[directory]
style = "blue"

[character]
success_symbol = "[❯](purple)"
error_symbol = "[❯](red)"
vimcmd_symbol = "[❮](green)"

[git_branch]
format = "[$branch]($style)"
style = "bright-black"

[git_status]
format = "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)"
style = "cyan"
conflicted = ""
untracked = ""
modified = ""
staged = ""
renamed = ""
deleted = ""
stashed = ""

[git_state]
format = '\([$state( $progress_current/$progress_total)]($style)\) '
style = "bright-black"

[cmd_duration]
format = "[$duration]($style) "
style = "yellow"

[python]
format = "[$virtualenv]($style) "
style = "bright-black"
12 changes: 12 additions & 0 deletions .devcontainer/rootfs/home/vscode/.zsh_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
: 1640995200:0;atmos terraform plan myapp --stack dev
: 1640995201:0;atmos terraform plan myapp --stack staging
: 1640995202:0;atmos terraform plan myapp --stack prod
: 1640995203:0;atmos terraform apply myapp --stack dev
: 1640995204:0;atmos terraform apply myapp --stack staging
: 1640995205:0;atmos terraform apply myapp --stack prod
: 1640995206:0;atmos terraform plan myapp --stack dev
: 1640995207:0;atmos terraform plan myapp --stack staging
: 1640995208:0;atmos terraform plan myapp --stack prod
: 1640995209:0;atmos terraform deploy myapp --stack dev
: 1640995210:0;atmos terraform deploy myapp --stack staging
: 1640995211:0;atmos terraform deploy myapp --stack prod
37 changes: 37 additions & 0 deletions .devcontainer/rootfs/home/vscode/.zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
eval "$(direnv hook zsh)"

# VSCode shell integration
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"

export KUBECONFIG=${KUBECONFIG:-/workspace/examples/demo-helmfile/kubeconfig.yaml}

export CODESPACE_HOSTNAME="${CODESPACE_NAME}-80.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
export CODESPACE_HTTP_HOSTNAME="${CODESPACE_NAME}-80.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
export CODESPACE_HTTPS_HOSTNAME="${CODESPACE_NAME}-443.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"

export CODESPACE_URL="http://${CODESPACE_HOSTNAME}"
export CODESPACE_HTTP_URL="http://${CODESPACE_HTTP_HOSTNAME}"
export CODESPACE_HTTPS_URL="http://${CODESPACE_HTTPS_HOSTNAME}"

# Install atmos completion
eval $(atmos completion zsh)

# Setup some aliases
alias tree='tree -CAF --gitignore -I ".git" -I "terraform.tfstate*"'
alias bat='bat --style header,numbers --theme="GitHub"'

# Disable directory entry messages
export DIRENV_LOG_FORMAT=""

find /workspace/examples -name '.envrc' -execdir direnv allow \;

# Enable Starship prompt
eval "$(starship init zsh)"

# Celebrate! 🎉
if [ "${TERM}" != "screen.xterm-256color" ]; then
timeout --preserve-status 2 confetty
fi

# Show the version of atmos installed
atmos version
Loading

0 comments on commit b53d696

Please sign in to comment.