Skip to content

Commit

Permalink
fix(devcontainer): Add root user permissions for docker image build (#…
Browse files Browse the repository at this point in the history
…167)

* fix(devcontainer): Add root user permissions for docker image build

* fix(devcontainer): Create appuser and switch from root after install deps
  • Loading branch information
LinnJS authored Nov 21, 2024
1 parent 1c85d90 commit 1f47aaf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM --platform=linux/amd64 ghcr.io/rails/devcontainer/images/ruby:3.2.2

# Switch to root to install dependencies
USER root

RUN set -xe \
&& apt update && apt -y upgrade

Expand Down Expand Up @@ -32,9 +35,10 @@ RUN set -xe \
&& apt update \
&& apt -y install --no-install-recommends google-chrome-stable

# Create a User
# Create a non-root user
RUN set -xe \
&& echo 'ALL ALL = (ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
&& useradd -m -s /bin/bash appuser \
&& echo 'appuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Install NodeJS
RUN set -xe \
Expand All @@ -48,3 +52,6 @@ RUN set -xe \
# Install Application Dependencies
RUN set -xe \
&& apt -y install --no-install-recommends libpq-dev imagemagick libvips-dev libvips-tools libvips42 ruby-chromedriver-helper ruby-foreman

# Switch to non-root user
USER appuser

0 comments on commit 1f47aaf

Please sign in to comment.