Skip to content

Commit 5e3b1ee

Browse files
Update dockerfile in devcontainers for permission errors in vscode
1 parent 570ce13 commit 5e3b1ee

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y \
99
curl \
1010
vim \
1111
procps \
12+
gosu \
1213
&& rm -rf /var/lib/apt/lists/*
1314

1415
# Set working directory
@@ -22,14 +23,26 @@ ARG USERNAME=node
2223
ARG USER_UID=1000
2324
ARG USER_GID=$USER_UID
2425

25-
# Set ownership
26-
RUN chown -R $USERNAME:$USERNAME /workspaces
27-
28-
# Switch to non-root user
29-
USER $USERNAME
26+
# Create directories that will be mounted as volumes
27+
# These will be overridden by volumes, but entrypoint will fix permissions
28+
RUN mkdir -p /workspaces/simplens-core/node_modules \
29+
&& mkdir -p /home/$USERNAME/.vscode-server/extensions \
30+
&& chown -R $USERNAME:$USERNAME /workspaces \
31+
&& chown -R $USERNAME:$USERNAME /home/$USERNAME/.vscode-server
32+
33+
# Create entrypoint script to fix volume permissions
34+
RUN echo '#!/bin/bash\n\
35+
# Fix ownership of mounted volumes (runs as root)\n\
36+
chown -R node:node /workspaces/simplens-core/node_modules 2>/dev/null || true\n\
37+
chown -R node:node /home/node/.vscode-server 2>/dev/null || true\n\
38+
# Execute the main command as the node user\n\
39+
exec gosu node "$@"' > /usr/local/bin/entrypoint.sh \
40+
&& chmod +x /usr/local/bin/entrypoint.sh
3041

3142
# Default shell
3243
ENV SHELL=/bin/bash
3344

45+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
46+
3447
# Keep container running
3548
CMD ["sleep", "infinity"]

0 commit comments

Comments
 (0)