File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
4647ENV NPM_CONFIG_PREFIX=/home/runner/.npm-global
4748# 2. Add the new global bin directory to the PATH
4849ENV 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
5653RUN 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+
5961USER runner
You canāt perform that action at this time.
0 commit comments