Skip to content

Commit

Permalink
Merge pull request #3 from epics-containers/dev
Browse files Browse the repository at this point in the history
Commenting the dev container files
  • Loading branch information
gilesknap authored Oct 13, 2023
2 parents 950727b + e280f05 commit 7e4d132
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
17 changes: 14 additions & 3 deletions .devcontainer/.bashrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
################################################################################
# epics-containers developer shell configuration.
# This is a standard ubuntu .bashrc plus a call to .bashrc_dev_container
# in the user's home directory on the host machine.
# This is a standard ubuntu .bashrc plus a PS1 prompt with container name
# and a call to .bashrc_dev_container in the user's home directory on the
# host machine.
################################################################################

# ~/.bashrc: executed by bash(1) for non-login shells.
Expand Down Expand Up @@ -62,10 +63,20 @@ if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

# make a useful prompt, including current container name
EC_PROJECT=${EC_PROJECT:-container}
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ "
export PS1="[\[\e[31m\]${EC_PROJECT#'ioc-'}\[\e[m\]]${PS1}"
source /root/.bash_completions/ibek.sh

# add user's custom .bashrc_dev_container
if [ -f ~/.bashrc_dev_container ]; then
. ~/.bashrc_dev_container
fi

source /root/.bash_completions/ibek.sh


18 changes: 17 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
}
},
"remoteEnv": {
"DISPLAY": "${localEnv:DISPLAY}"
// allows X11 apps to run inside the container
"DISPLAY": "${localEnv:DISPLAY}",
// provides a name for epics-containers to use in bash prompt etc.
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"customizations": {
"vscode": {
Expand All @@ -29,23 +32,36 @@
}
},
// Make sure the files we are mapping into the container exist on the host
// You can place any other outside of the container before-launch commands here
"initializeCommand": "bash .devcontainer/initializeCommand ${devcontainerId}",
// Hooks the global .bashprofile_dev_container but also can add any other commands
// to run in the container at creation in here
"postCreateCommand": "bash .devcontainer/postCreateCommand ${devcontainerId}",
"runArgs": [
// Allow the container to access the host X11 display and EPICS CA
"--net=host",
// Make sure podman can see all host filesystems. WARNING: not compatible with docker
"--security-opt=label=disable"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/epics/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/epics/${localWorkspaceFolderBasename}",
"mounts": [
// Mount some useful local files from the user's home directory
// By mounting the parent of the workspace we can work on multiple peer projects
"source=${localWorkspaceFolder}/../,target=/repos,type=bind",
// this provides eternal bash history in and out of the container
"source=${localEnv:HOME}/.bash_eternal_history,target=/root/.bash_eternal_history,type=bind",
// this bashrc hooks up the .bashrc_dev_container in the following mount
"source=${localWorkspaceFolder}/.devcontainer/.bashrc,target=/root/.bashrc,type=bind",
// provides a place for you to put your shell customizations for all your dev containers
"source=${localEnv:HOME}/.bashrc_dev_container,target=/root/.bashrc_dev_container,type=bind",
// provides a place to install any packages you want to have across all your dev containers
"source=${localEnv:HOME}/.bashprofile_dev_container,target=/root/.bashprofile_dev_container,type=bind",
// ensures your git name and email are set correctly
"source=${localEnv:HOME}/.gitconfig,target=/root/.gitconfig,type=bind",
// provides the same command line editing experience as your host
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind",
// provides the same ssh keys as your host
"source=${localEnv:HOME}/.ssh,target=/root/.ssh,type=bind"
]
}
1 change: 1 addition & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if [[ "${PUSH}" == 'true' ]] ; then EC_PUSH='--push' ; fi

THIS=$(dirname ${0})
set -xe
mkdir -p ${CACHE}

# get the current version of ec CLI
pip install -r ${THIS}/../../requirements.txt
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
"titleBar.activeBackground": "#800E42",
"titleBar.activeForeground": "#FFFCFD"
},
"python.pythonPath": "/venv/bin/python3",
}
13 changes: 0 additions & 13 deletions user_examples/.bashrc_dev_container
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,3 @@ if [[ ! -f /tmp/git-completion.bash ]]; then
wget -q -P /tmp https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
fi
source /tmp/git-completion.bash

# add ibek completion if available
( source <(ibek --show-completion bash) ) &> /dev/null

function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

# make a useful prompt, including current container name
PS1="\[\e[32m\]\$(parse_git_branch)\[\e[m\][\[\e[34m\]\[\e[m\]\W]\$ "
export PS1="[\[\e[31m\]${PROJECT_NAME:-container}\[\e[m\]]${PS1}"


0 comments on commit 7e4d132

Please sign in to comment.