Skip to content

Commit f1472ff

Browse files
authored
chore: run devcontainer as user vscode instead of root (ietf-tools#3948)
1 parent f4ce041 commit f1472ff

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@
9696
"label": "MariaDB",
9797
"onAutoForward": "silent"
9898
}
99-
}
99+
},
100100

101101
// Use 'postCreateCommand' to run commands after the container is created.
102102
// "postCreateCommand": "sh /docker-init.sh",
103103

104104
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
105-
// "remoteUser": "django"
105+
"remoteUser": "vscode"
106106
}

docker/app.Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ ENV LC_ALL en_US.UTF-8
114114
ADD https://raw.githubusercontent.com/ietf-tools/idnits-mirror/main/idnits /usr/local/bin/
115115
RUN chmod +rx /usr/local/bin/idnits
116116

117-
# Install current datatracker python dependencies
118-
COPY requirements.txt /tmp/pip-tmp/
119-
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
120-
&& rm -rf /tmp/pip-tmp
121-
122117
# Turn off rsyslog kernel logging (doesn't work in Docker)
123118
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
124119

@@ -137,4 +132,11 @@ RUN sed -i 's/\r$//' /docker-init.sh && \
137132
RUN mkdir -p /workspace
138133
WORKDIR /workspace
139134

135+
USER vscode:vscode
136+
137+
# Install current datatracker python dependencies
138+
COPY requirements.txt /tmp/pip-tmp/
139+
RUN pip3 --disable-pip-version-check --no-cache-dir install --user -r /tmp/pip-tmp/requirements.txt
140+
RUN sudo rm -rf /tmp/pip-tmp
141+
140142
# ENTRYPOINT [ "/docker-init.sh" ]

docker/scripts/app-init.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
WORKSPACEDIR="/workspace"
44

5-
service rsyslog start
5+
sudo service rsyslog start
66

77
# fix permissions for npm-related paths
88
WORKSPACE_UID_GID=$(stat --format="%u:%g" "$WORKSPACEDIR")
9-
chown -R "$WORKSPACE_UID_GID" "$WORKSPACEDIR/.parcel-cache"
9+
sudo chown -R "$WORKSPACE_UID_GID" "$WORKSPACEDIR/.parcel-cache"
1010

1111
# Build node packages that requrie native compilation
1212
echo "Compiling native node packages..."
@@ -71,7 +71,8 @@ fi
7171

7272
# Run memcached
7373

74-
/usr/bin/memcached -u root -d
74+
echo "Starting memcached..."
75+
/usr/bin/memcached -u vscode -d
7576

7677
# Initial checks
7778

@@ -99,6 +100,6 @@ if [ -z "$EDITOR_VSCODE" ]; then
99100
bash -c "$*"
100101
CODE=$?
101102
fi
102-
service rsyslog stop
103+
sudo service rsyslog stop
103104
exit $CODE
104105
fi

0 commit comments

Comments
 (0)