Skip to content

Commit 4e86142

Browse files
committed
Run frontend Docker installs as non-root
1 parent 9823258 commit 4e86142

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

frontend/Dockerfile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ RUN apt-get update -qq && \
88

99
RUN npm i -g npm@6.14.18
1010

11+
COPY bin/docker-entrypoint /usr/local/bin/frontend-entrypoint
12+
13+
RUN chmod +x /usr/local/bin/frontend-entrypoint && \
14+
chown -R node:node /app
15+
1116
ENV CHROME_BIN=/usr/bin/chromium
1217
ENV OPENSSL_CONF=/dev/null
1318

14-
COPY package*.json bower.json .bowerrc .npmrc ./
15-
COPY patches ./patches
19+
USER node
20+
21+
COPY --chown=node:node package*.json bower.json .bowerrc .npmrc ./
22+
COPY --chown=node:node patches ./patches
1623

17-
RUN npm install --unsafe-perm && \
24+
RUN npm install && \
1825
{ \
1926
for file in package.json package-lock.json bower.json .bowerrc .npmrc; do \
2027
[ -f "$file" ] && sha256sum "$file"; \
@@ -24,11 +31,7 @@ RUN npm install --unsafe-perm && \
2431
done; \
2532
} | sha256sum | awk '{print $1}' > ./node_modules/.docker-dependencies-checksum
2633

27-
COPY bin/docker-entrypoint /usr/local/bin/frontend-entrypoint
28-
29-
RUN chmod +x /usr/local/bin/frontend-entrypoint
30-
31-
COPY . .
34+
COPY --chown=node:node . .
3235

3336
ENTRYPOINT ["/usr/local/bin/frontend-entrypoint"]
3437

frontend/bin/docker-entrypoint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ current_checksum="$(dependencies_checksum)"
2121
if [ ! -x ./node_modules/.bin/ember ] ||
2222
[ ! -f "$checksum_file" ] ||
2323
[ "$(cat "$checksum_file")" != "$current_checksum" ]; then
24-
npm install --unsafe-perm
24+
npm install
2525
printf '%s\n' "$current_checksum" > "$checksum_file"
2626
fi
2727

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"license": "MIT",
1212
"author": "",
1313
"scripts": {
14-
"postinstall": "patch-package && ./node_modules/bower/bin/bower --allow-root install",
14+
"postinstall": "patch-package && ./node_modules/bower/bin/bower install",
1515
"build": "ember build --environment=production",
1616
"lint:js": "eslint ./*.js app config lib server tests",
1717
"start": "serve dist -l ${PORT:-4300} -s",

0 commit comments

Comments
 (0)