Skip to content

Commit 1f47aaf

Browse files
authored
fix(devcontainer): Add root user permissions for docker image build (#167)
* fix(devcontainer): Add root user permissions for docker image build * fix(devcontainer): Create appuser and switch from root after install deps
1 parent 1c85d90 commit 1f47aaf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM --platform=linux/amd64 ghcr.io/rails/devcontainer/images/ruby:3.2.2
22

3+
# Switch to root to install dependencies
4+
USER root
5+
36
RUN set -xe \
47
&& apt update && apt -y upgrade
58

@@ -32,9 +35,10 @@ RUN set -xe \
3235
&& apt update \
3336
&& apt -y install --no-install-recommends google-chrome-stable
3437

35-
# Create a User
38+
# Create a non-root user
3639
RUN set -xe \
37-
&& echo 'ALL ALL = (ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
40+
&& useradd -m -s /bin/bash appuser \
41+
&& echo 'appuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
3842

3943
# Install NodeJS
4044
RUN set -xe \
@@ -48,3 +52,6 @@ RUN set -xe \
4852
# Install Application Dependencies
4953
RUN set -xe \
5054
&& apt -y install --no-install-recommends libpq-dev imagemagick libvips-dev libvips-tools libvips42 ruby-chromedriver-helper ruby-foreman
55+
56+
# Switch to non-root user
57+
USER appuser

0 commit comments

Comments
 (0)