From 25aedd24ed08181850b7526fef0cd8cffbe5cd77 Mon Sep 17 00:00:00 2001 From: Benedek Kozma Date: Mon, 7 Oct 2024 20:40:51 +0200 Subject: [PATCH 1/3] Fix build error due to conflicting uid:gid --- src/swift/.devcontainer/devcontainer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/swift/.devcontainer/devcontainer.json b/src/swift/.devcontainer/devcontainer.json index 3c09300..05db078 100644 --- a/src/swift/.devcontainer/devcontainer.json +++ b/src/swift/.devcontainer/devcontainer.json @@ -4,9 +4,6 @@ "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "false", - "username": "vscode", - "userUid": "1000", - "userGid": "1000", "upgradePackages": "false" }, "ghcr.io/devcontainers/features/git:1": { @@ -36,6 +33,9 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + // The default swift docker image variant is built on Ubuntu, which creates the `ubuntu` user with uid:gid 1000:1000. + // We are using this user and updating its uid:gid to match the local user that is running the devcontainer, + // so that files created inside the devcontainer will belong to the local user. + "remoteUser": "ubuntu", + "updateRemoteUserUID": true } From ea7cb7dfc29f5d665d5bea60591570f9fb750022 Mon Sep 17 00:00:00 2001 From: Benedek Kozma Date: Mon, 7 Oct 2024 23:42:43 +0200 Subject: [PATCH 2/3] Set containerUser instead of remoteUser --- src/swift/.devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swift/.devcontainer/devcontainer.json b/src/swift/.devcontainer/devcontainer.json index 05db078..a63cc57 100644 --- a/src/swift/.devcontainer/devcontainer.json +++ b/src/swift/.devcontainer/devcontainer.json @@ -36,6 +36,6 @@ // The default swift docker image variant is built on Ubuntu, which creates the `ubuntu` user with uid:gid 1000:1000. // We are using this user and updating its uid:gid to match the local user that is running the devcontainer, // so that files created inside the devcontainer will belong to the local user. - "remoteUser": "ubuntu", + "containerUser": "ubuntu", "updateRemoteUserUID": true } From 26d1e501467e7279fc57c63de75e6aa7be66f8de Mon Sep 17 00:00:00 2001 From: Benedek Kozma Date: Wed, 9 Oct 2024 11:48:22 +0200 Subject: [PATCH 3/3] Use vscode user --- src/swift/.devcontainer/Dockerfile | 6 ++++++ src/swift/.devcontainer/devcontainer.json | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 src/swift/.devcontainer/Dockerfile diff --git a/src/swift/.devcontainer/Dockerfile b/src/swift/.devcontainer/Dockerfile new file mode 100644 index 0000000..e30ea8d --- /dev/null +++ b/src/swift/.devcontainer/Dockerfile @@ -0,0 +1,6 @@ +ARG SWIFT_VERSION +FROM swift:${SWIFT_VERSION} + +RUN if id "ubuntu" &>/dev/null; then \ + echo "Deleting user 'ubuntu'" && userdel -f -r ubuntu || echo "Failed to delete 'ubuntu' user"; \ + fi diff --git a/src/swift/.devcontainer/devcontainer.json b/src/swift/.devcontainer/devcontainer.json index a63cc57..bf99767 100644 --- a/src/swift/.devcontainer/devcontainer.json +++ b/src/swift/.devcontainer/devcontainer.json @@ -1,9 +1,16 @@ { "name": "Swift", - "image": "swift:${templateOption:imageVariant}", + "build": { + "dockerfile": "./Dockerfile", + "context": ".", + "args": { + "SWIFT_VERSION": "${templateOption:imageVariant}" + } + }, "features": { "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "false", + "username": "vscode", "upgradePackages": "false" }, "ghcr.io/devcontainers/features/git:1": { @@ -33,9 +40,5 @@ // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // The default swift docker image variant is built on Ubuntu, which creates the `ubuntu` user with uid:gid 1000:1000. - // We are using this user and updating its uid:gid to match the local user that is running the devcontainer, - // so that files created inside the devcontainer will belong to the local user. - "containerUser": "ubuntu", - "updateRemoteUserUID": true + "containerUser": "vscode" }