Skip to content

Commit

Permalink
Fix docker nodejs permission in MacOS
Browse files Browse the repository at this point in the history
Signed-off-by: Son Bui <[email protected]>
  • Loading branch information
sonbui00 committed Nov 25, 2024
1 parent ae93691 commit 095416b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compose.override.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ services:
ports:
- "80:80"
nodejs:
image: node:${NODE_VERSION:-20}-alpine
build:
context: docker/nodejs
args:
- NODE_VERSION:${NODE_VERSION:-20}
user: ${DOCKER_USER:-1000:1000}
working_dir: /srv/sylius
entrypoint: [ "/bin/sh","-c" ]
command:
- |
npm install
Expand Down
27 changes: 27 additions & 0 deletions docker/nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG NODE_VERSION=20
ARG FIXUID_VERSION=0.6.0

FROM node:${NODE_VERSION}-alpine

ARG FIXUID_VERSION

RUN apk --no-cache add curl

COPY docker-entrypoint /usr/local/bin/

RUN USER=node && \
GROUP=node && \
if [[ "$(uname -m)" = "aarch64" ]] ; \
then \
curl -SsL https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-arm64.tar.gz | tar -C /usr/local/bin -xzf - ;\
else \
curl -SsL https://github.com/boxboat/fixuid/releases/download/v${FIXUID_VERSION}/fixuid-${FIXUID_VERSION}-linux-amd64.tar.gz | tar -C /usr/local/bin -xzf - ;\
fi; \
chown root:root /usr/local/bin/fixuid && \
chmod 4755 /usr/local/bin/fixuid && \
mkdir -p /etc/fixuid && \
printf "user: $USER\ngroup: $GROUP\n" > /etc/fixuid/config.yml

USER node:node

ENTRYPOINT ["docker-entrypoint"]
11 changes: 11 additions & 0 deletions docker/nodejs/docker-entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

eval $( fixuid )

if [ $# -eq 1 ]; then
# Use a subshell to execute the potentially multiline command
exec /bin/sh -c "$1"
else
exec "$@"
fi

0 comments on commit 095416b

Please sign in to comment.