Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker support to developer container #4

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .devcontainer/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ function parse_git_branch {
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

# ibek cli completion
source <(ibek --show-completion bash)

# add user's custom .bashrc_dev_container
if [ -f ~/.bashrc_dev_container ]; then
Expand Down
17 changes: 12 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
// provides a name for epics-containers to use in bash prompt etc.
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": false,
"installOhMyZsh": false,
"installOhMyZshConfig": false,
"upgradePackages": false
}
},
// IMPORTANT for this devcontainer to work with docker EC_REMOTE_USER must be
// set to vscode. For podman it should be left blank.
"remoteUser": "${localEnv:EC_REMOTE_USER}",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
Expand Down Expand Up @@ -57,11 +68,7 @@
"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"
"source=${localEnv:HOME}/.inputrc,target=/root/.inputrc,type=bind"
]
}
3 changes: 1 addition & 2 deletions .devcontainer/initializeCommand
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ for i in \
.bash_eternal_history \
.bashrc_dev_container \
.bashprofile_dev_container \
.inputrc \
.gitconfig
.inputrc
do
if [ ! -f $HOME/$i ] ; then
touch $HOME/$i;
Expand Down
31 changes: 23 additions & 8 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
#!/bin/bash

# the IOC is made at build time but the devcontainer mounts over the top of it
# so we need to regenerate it for devcontainer use
################################################################################
# When using docker we will not be root inside the container
# the following steps are then required
################################################################################

# get the ioc template, generate makefile and compile.
# Commented out because compilation failures stop the devcontainer from starting
# best to let the user do this manually once inside the container
if [[ $USER != "root" ]] ; then
# make sure the non-root user can build iocs and (mounted in) support modules
sudo chown -R ${USER}:${USER} /epics/links
sudo chown -h ${USER}:${USER} /epics /epics/ioc

# ibek ioc compile
# also give non-root user access to the same bash config we use in podman
sudo chmod a+rx /root
for f in .inputrc .bash_eternal_history .bashrc .bashrc_dev_container; do
sudo chmod a+rw /root/$f
ln -sf /root/$f $HOME/$f
done
fi

# add user's custom profile
################################################################################
# Custom install script for each developer to add whatever they like to
# all epics-containers devcontainers
################################################################################


# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
. ~/.bashprofile_dev_container
fi
fi
10 changes: 1 addition & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"workbench.colorCustomizations": {
"activityBar.background": "#5B0A2F",
"titleBar.activeBackground": "#800E42",
"titleBar.activeForeground": "#FFFCFD"
},
"python.pythonPath": "/venv/bin/python3",
"python.defaultInterpreterPath": "/venv/bin/python"
}
Loading