Skip to content

Commit a38700f

Browse files
authored
🐳 Update Dockerfile
1 parent be1dcb6 commit a38700f

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

ā€ŽDockerfileā€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,20 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
4242

4343
# --- CONFIGURE NPM FOR GLOBAL INSTALLS AS NON-ROOT ---
4444
# 1. Create a directory for global packages and set npm to use it
45-
RUN mkdir -p /home/runner/.npm-global
45+
RUN mkdir -p /home/runner/.npm-global \
46+
&& mkdir -p /home/runner/.npm
4647
ENV NPM_CONFIG_PREFIX=/home/runner/.npm-global
4748
# 2. Add the new global bin directory to the PATH
4849
ENV PATH=$NPM_CONFIG_PREFIX/bin:$PATH
49-
# 3. Give the runner user ownership of this new directory ONLY
50-
RUN chown -R runner:runner /home/runner/.npm-global \
51-
&& mkdir -p /home/runner/.npm \
52-
&& chown -R 1001:1001 /home/runner/.npm
5350
# --- END OF NPM CONFIGURATION ---
5451

5552
# Install global npm packages and AWS SAM CLI
5653
RUN npm install -g yarn @redocly/cli \
5754
&& pip3 install --no-cache-dir aws-sam-cli
5855

56+
# --- FIX PERMISSIONS ---
57+
# After root has run npm, change ownership of the cache and global install
58+
# directories to the runner user. This is the crucial step.
59+
RUN chown -R runner:runner /home/runner/.npm /home/runner/.npm-global
60+
5961
USER runner

0 commit comments

Comments
Ā (0)