Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker nodejs permission in MacOS #1079

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading