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

Caching home directory for remoteUser after feature install #774

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

prulloac
Copy link

@prulloac prulloac commented Mar 16, 2024

Adds coalescing logic following how commons-utils feature handles home directories for users that do not have one from source image. [Updated]

Caching container user home directory and remote user home directory after any feature installs, this will increase build time in a matter of milliseconds but will ensure that after each feature layer, the _CONTAINER_USER_HOME and _REMOTE_USER_HOME will be updated and cached for the next feature to be installed.

This should solve issue #331 .

Open to suggestions on how to improve, adding same coalesce for _CONTAINER_USER_HOME does not break anything, but didn't want to include that until told otherwise by maintainers.

Locally tested as follows:

  • using a devcontainer.json as follows
{
	"name": "test",
	"image": "ubuntu:jammy",
	"features": {
		"ghcr.io/devcontainers/features/common-utils:2": {
			"username": "vscode",
			"installZsh": true,
			"installOhMyZsh": true,
			"upgradePackages": true
		},
		"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}
	},
	"remoteUser": "vscode"
}
  • compiled with yarn
  • built the test devcontainer with node devcontainer.js build --config test/devcontainer.json --workspace-folder .
  • started the test devcontainer with node devcontainer.js up --config test/devcontainer.json --workspace-folder .
  • enter the running devcontiner with docker exec -it <CONTAINER_NAME> sh
  • verified shell-history feature installed correctly for the newly created user

Tested with host:

  • windows with wsl, intel chipset
  • osx sonoma, m1 chipset
  • codespace with repository devcontainer.json configuration

package.json Outdated Show resolved Hide resolved
src/spec-configuration/containerFeaturesConfiguration.ts Outdated Show resolved Hide resolved
@prulloac prulloac changed the title Coalescing home directory for remoteUser following commons-utils logic Caching home directory for remoteUser after every feature install Apr 2, 2024
@prulloac prulloac changed the title Caching home directory for remoteUser after every feature install Caching home directory for remoteUser after feature install Apr 2, 2024
@chrmarti
Copy link
Contributor

Tests need to be updated (see test failures). It would also be great to have a test specifically for this where a first feature creates a user and a second feature then checks if the env variables are updated correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants