Skip to content

Commit

Permalink
Add a devcontainer with brew so I can work on ipad
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguest75 committed Sep 11, 2024
1 parent b0d3609 commit 3ea0aaf
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .devcontainer/07_oh_my_zsh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends locales

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

USER root

ENTRYPOINT ["/bin/zsh"]
CMD ["/bin/zsh"]
62 changes: 62 additions & 0 deletions .devcontainer/07_oh_my_zsh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# README

Demonstrate a simple `zsh` container using features.

Demonstrates:

* Using features
* It seems to be much quicker to build.

TODO:

* Configure zsh correctly (niceprompt).

## Contents

- [README](#readme)
- [Contents](#contents)
- [Start (vscode)](#start-vscode)
- [Run tests](#run-tests)
- [Stop](#stop)
- [Resources](#resources)

## Start (vscode)

Use the Remote Containers extension and select "Reopen in Container" or...

```sh
# start devcontainer
./devcontainerctl.sh -n=07_oh_my_zsh

# start devcontainer (rebuild)
./devcontainerctl.sh -n=07_oh_my_zsh --no-cache
```

Use `⌘ + ^ + p` and "Dev Containers: Attach to a running container"

Add `/workspaces/devcontainer_examples` as a workspace to the new vscode editor.

```sh
cd /workspaces/devcontainer_examples
```

## Run tests

```sh
cd ./07_oh_my_zsh
echo $DEVCONTAINER_TYPE
```

## Stop

```sh
# stop devcontainer
./devcontainerctl.sh -n=07_oh_my_zsh --down
```

## Resources

* devcontainers/cli repo [here](https://github.com/devcontainers/cli)
* devcontainers-contrib/features repo [here](https://github.com/devcontainers-contrib/features)
* codespaces-multi-repository-monorepo-scenarios blog [here](https://github.blog/2022-04-20-codespaces-multi-repository-monorepo-scenarios/)
* integrated-terminal config [here](https://code.visualstudio.com/docs/editor/integrated-terminal)
66 changes: 66 additions & 0 deletions .devcontainer/07_oh_my_zsh/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/ubuntu
{
"name": "07_oh_my_zsh",
"build": {
"dockerfile": "Dockerfile",
"context": ".",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": { "VARIANT": "ubuntu-22.04" }
},
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bash /workspaces/devcontainer_examples/.devcontainer/07_oh_my_zsh/postCreateCommand.sh",

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

"containerUser": "root",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "root",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": true,
"installZsh": true,
"installOhMyZsh": true,
"username": "root"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "latest"
},
"ghcr.io/meaningful-ooo/devcontainer-features/homebrew:2": {
"version": "latest",
"shallowClone": true
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-azuretools.vscode-docker",
"oderwat.indent-rainbow",
"timonwong.shellcheck",
"DavidAnson.vscode-markdownlint"
]
},
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh"
}
},
"containerEnv": {
"MY_TEST_SECRET": "${localEnv:TEST_SECRET}",
"MY_VARIABLE": "${localEnv:MY_VARIABLE}",
"DEVCONTAINER_TYPE": "07_oh_my_zsh"
},
// NOTE: THIS IS NOT WORKING
// --mount-workspace-git-root false
// ,"workspaceMount": "source=${localWorkspaceFolder}/01_bash_container,target=/workspace,type=bind,consistency=cached",
// "workspaceFolder": "/workspace"
}
8 changes: 8 additions & 0 deletions .devcontainer/07_oh_my_zsh/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash/env bash
echo "Executing postCreateCommand.sh"
echo "uname: $(uname -a)"
echo "whoami: $(whoami)"

sed -i.bak "s/ZSH_THEME=\"codespaces\"/ZSH_THEME=\"robbyrussell\"/g" /root/.zshrc
sed -i.bak "s/ZSH_THEME=\"codespaces\"/ZSH_THEME=\"robbyrussell\"/g" ~/.zshrc

0 comments on commit 3ea0aaf

Please sign in to comment.