|
1 | 1 | # ubuntu-devcontainer |
2 | | -Opinionated Ubuntu based devcontainer for python and EPICS development |
| 2 | + |
| 3 | +Opinionated Ubuntu based devcontainer for python and EPICS development, tagged in step with upstream ubuntu for runtime. |
| 4 | + |
| 5 | +Features: |
| 6 | +- User customisable bash/zsh environment |
| 7 | +- Cross container persistent shell history |
| 8 | +- git, curl make and other build-essentials |
| 9 | +- uv for python environment management |
| 10 | +- ssh, gdb and busybox for runtime debugging |
| 11 | + |
| 12 | +## How to use from the commandline |
| 13 | + |
| 14 | +To try it out without persistent shell history: |
| 15 | + |
| 16 | +```bash |
| 17 | +podman run -it ghcr.io/diamondlightsource/ubuntu-devcontainer |
| 18 | +``` |
| 19 | + |
| 20 | +To keep the history and allow shell customisation: |
| 21 | + |
| 22 | +```bash |
| 23 | +mkdir -p $HOME/.config/terminal-config |
| 24 | +podman run --mount type=bind,src=$HOME/.config/terminal-config,target=/user-terminal-config -it ghcr.io/diamondlightsource/ubuntu-devcontainer |
| 25 | +``` |
| 26 | + |
| 27 | +To do the above but with zsh: |
| 28 | + |
| 29 | +```bash |
| 30 | +mkdir -p $HOME/.config/terminal-config |
| 31 | +podman run --mount type=bind,src=$HOME/.config/terminal-config,target=/user-terminal-config -it ghcr.io/diamondlightsource/ubuntu-devcontainer zsh |
| 32 | +``` |
| 33 | + |
| 34 | +## How to customize your shell |
| 35 | + |
| 36 | +When mounting in `$HOME/.config/terminal-config`, the container will create the following files in the directory: |
| 37 | +- `bashrc`: loading some bash defaults |
| 38 | +- `zshrc`: loading some zsh defaults |
| 39 | +- `inputrc`: to customize the behaviour of up arrow etc in both shells |
| 40 | + |
| 41 | +You are free to edit any of these files, adding overrides before or after the loading of the defaults, or even removing the loading of the defaults altogether. |
| 42 | + |
| 43 | +History is also stored in this directory, in `.bash_eternal_history` and `.zsh_eternal_history` respectively. |
| 44 | + |
| 45 | +## How to use as a devcontainer |
| 46 | + |
| 47 | +See [this repo's `.devcontainer.json`](./.devcontainer.json) for an example on how to use as a devcontainer. Or clone this repo, open in vscode and click "reopen in container" |
| 48 | + |
| 49 | +## How to use in the build stage of a Dockerfile |
| 50 | + |
| 51 | +If you are using this during the build stage of a Dockerfile, then you should select the upstream `ubuntu` container for the runtime. |
| 52 | + |
| 53 | +For instance: |
| 54 | + |
| 55 | +```Dockerfile |
| 56 | +# The developer stage is used as a devcontainer including dev versions |
| 57 | +# of the build dependencies |
| 58 | +FROM ghcr.io/diamondlightsource/ubuntu-devcontainer:noble AS developer |
| 59 | +RUN apt-get update -y && apt-get install -y --no-install-recommends \ |
| 60 | + libevent-dev \ |
| 61 | + libreadline-dev |
| 62 | + |
| 63 | +# The build stage makes some assets using the developer tools |
| 64 | +FROM developer AS build |
| 65 | +RUN my-build-script.sh /assets |
| 66 | + |
| 67 | +# The runtime stage installs runtime deps then copies in built assets |
| 68 | +# This time we remove the apt lists to save disk space |
| 69 | +FROM ubuntu:noble as runtime |
| 70 | +RUN apt-get update -y && apt-get install -y --no-install-recommends \ |
| 71 | + libevent \ |
| 72 | + libreadline \ |
| 73 | + && rm -rf /var/lib/apt/lists/* |
| 74 | +COPY --from=build /assets / |
| 75 | +``` |
| 76 | + |
0 commit comments