From e6542fd041d8dee915edb0457a7448017f061e84 Mon Sep 17 00:00:00 2001 From: Giles Knap Date: Tue, 17 Oct 2023 10:26:51 +0000 Subject: [PATCH] try use of common utils 2 features --- .devcontainer/devcontainer.json | 4 ++++ .devcontainer/postCreateCommand | 42 ++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b32b965..90f3ceb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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. diff --git a/.devcontainer/postCreateCommand b/.devcontainer/postCreateCommand index 8f93677..61c8f59 100644 --- a/.devcontainer/postCreateCommand +++ b/.devcontainer/postCreateCommand @@ -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