Skip to content

Commit 472f76b

Browse files
Copilotrjaegers
andcommitted
Fix Rust Dockerfile user permissions and improve security
Co-authored-by: rjaegers <45816308+rjaegers@users.noreply.github.com>
1 parent efdf2b8 commit 472f76b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

.devcontainer/cpp/Dockerfile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,15 @@ RUN --mount=type=cache,target=/cache,sharing=locked \
130130
&& conan profile detect \
131131
&& echo -e "\n[conf]\ntools.cmake.cmaketoolchain:generator=Ninja" >> "$(conan profile path default)"
132132

133-
# Create cache directories with appropriate permissions for the code user
134-
RUN mkdir -p /cache/.ccache /cache/.cpm /cache/.python \
135-
&& chown -R code:code /cache \
136-
&& chmod -R 755 /cache
133+
# Create cache directories and conan directory with appropriate permissions for the code user
134+
RUN mkdir -p /cache/.ccache /cache/.cpm /cache/.python /opt/conan \
135+
&& chown -R code:code /cache /opt/conan \
136+
&& chmod -R 755 /cache /opt/conan
137137

138138
# Set up conan for the code user
139139
USER code
140140
RUN conan profile detect \
141141
&& echo -e "\n[conf]\ntools.cmake.cmaketoolchain:generator=Ninja" >> "$(conan profile path default)"
142142

143-
# Switch back to root temporarily for any remaining setup
144-
USER root
145-
146143
# Set the default user
147144
USER code

.devcontainer/rust/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ RUN groupadd --gid 1000 code \
7575
&& chown -R code:code /home/code
7676

7777
# Ensure the code user has access to cargo and rustup
78-
RUN chmod -R a+rX /usr/local/cargo /usr/local/rustup
78+
RUN chmod -R a+rX /usr/local/cargo /usr/local/rustup \
79+
&& chown -R code:code /usr/local/cargo /usr/local/rustup
7980

8081
# Set the default user
8182
USER code

0 commit comments

Comments
 (0)