Skip to content

Commit 43965e3

Browse files
pjungkampstv0g
authored andcommitted
Add a non-root "villas" user to the dev container for VS Code
This allow proper translation of file permissions on a Linux machine. See https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
1 parent 544b408 commit 43965e3

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp
33
{
44
"name": "VILLASnode",
5-
"image": "registry.git.rwth-aachen.de/acs/public/villas/node/dev:master",
5+
"image": "registry.git.rwth-aachen.de/acs/public/villas/node/dev-vscode:master",
66
// Uncomment to build the devcontainer locally
77
// "build": {
88
// "dockerfile": "../packaging/docker/Dockerfile.fedora",
9-
// "target": "dev",
9+
// "target": "dev-vscode",
1010
// "context": ".."
1111
// },
12+
"remoteUser": "villas",
1213
"runArgs": [ "--privileged", "--security-opt", "seccomp=unconfined"],
1314

1415
"extensions": [

packaging/docker/Dockerfile.fedora

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ ENV LANG C.UTF-8
103103

104104
WORKDIR /villas
105105

106+
FROM dev AS dev-vscode
107+
108+
# create a non-root user for vscode to use
109+
ARG USERNAME=villas
110+
ARG USER_UID=1000
111+
ARG USER_GID=$USER_UID
112+
113+
RUN groupadd --gid $USER_GID $USERNAME \
114+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
115+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
116+
&& chmod 0440 /etc/sudoers.d/$USERNAME
117+
106118
FROM dev AS app
107119

108120
COPY . /villas/

0 commit comments

Comments
 (0)