Skip to content

Commit

Permalink
try use of common utils 2 features
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Oct 17, 2023
1 parent 420189b commit e6542fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
// provides a name for epics-containers to use in bash prompt etc.
"EC_PROJECT": "${localWorkspaceFolderBasename}"
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {}
},
"remoteUser": "${localEnv:USER}",
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
Expand Down
42 changes: 25 additions & 17 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
# if we are using docker then we need to create a user that will write files
# with the correct user id. podmand runs as root inside but is really using
# the users' context and all file permissions just work.
if [[ ${container} != "podman" ]] ; then
# if [[ ${container} != "podman" ]] ; then

# create user dev with full sudo rights and make them owner of /epics
apt install sudo
echo 'dev ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
adduser dev -uid 1000 --disabled-password --gecos "temp devloper user with UID of host process"
usermod -aG sudo dev
echo "setting uid on writable container filesystem files ..."
chown dev:dev -R /epics/links
chown dev:dev /epics /epics/ioc
# TODO - testing replacing this with common utils feature
# which is much neater for docker but maybe not for podman
#
# # create user dev with full sudo rights and make them owner of /epics
# apt install sudo
# echo 'dev ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# adduser dev -uid 1000 --disabled-password --gecos "temp devloper user with UID of host process"
# usermod -aG sudo dev
# echo "setting uid on writable container filesystem files ..."
# chown dev:dev -R /epics/links
# chown dev:dev /epics /epics/ioc

# give the user the same shell config that root would get
chmod a+rx /root
for f in .bash_eternal_history .bashrc .bashrc_dev_container .gitconfig .inputrc .ssh;
do echo "handing $f to dev user"
chmod a+rw /root/$f
ln -fs /root/$f /home/dev/$f
done
fi
# # give the user the same shell config that root would get
# chmod a+rx /root
# for f in .bash_eternal_history .bashrc .bashrc_dev_container .gitconfig .inputrc .ssh;
# do echo "handing $f to dev user"
# chmod a+rw /root/$f
# ln -fs /root/$f /home/dev/$f
# done
# fi

# make sure the user can build iocs and (mounted in) support modules
env
sudo chown ${USER}:${USER} -R /epics/links
sudo chown ${USER}:${USER} /epics /epics/ioc

# add user's custom profile container creation script
if [ -f ~/.bashprofile_dev_container ]; then
Expand Down

0 comments on commit e6542fd

Please sign in to comment.