Skip to content

Commit

Permalink
Fix -dockerized execution #3137 (#3148) [ci fast]
Browse files Browse the repository at this point in the history
Signed-off-by: Kirill Bulert <bulert@infai.org>
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Signed-off-by: Mike Lee <michael.lee0517@gmail.com>
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
Co-authored-by: Mike Lee <michael.lee0517@gmail.com>
Co-authored-by: Phil Ewels <phil@seqera.io>
  • Loading branch information
4 people committed Nov 2, 2022
1 parent bae749f commit 64a81a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM amazoncorretto:17.0.4
RUN yum install -y procps-ng
RUN yum install -y procps-ng shadow-utils

ENV NXF_HOME=/.nextflow
ARG TARGETPLATFORM=linux/amd64
Expand Down
23 changes: 15 additions & 8 deletions docker/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#
# Finally it switches the `nextflow` user using the `su` command and
# executes the original target command line.
#
#
# authors:
# Paolo Di Tommaso
# Emilio Palumbo
Expand All @@ -39,20 +39,27 @@
# wrap cli args with single quote to avoid wildcard expansion
cli=''; for x in "$@"; do cli+="'$x' "; done

# the NXF_USRMAP hold the user ID in the host environment
# the NXF_USRMAP hold the user ID in the host environment
if [[ "$NXF_USRMAP" ]]; then
# create a `nextflow` user with the provided ID
# then change the docker socker ownership to `nextflow` user
addgroup docker
adduser -u $NXF_USRMAP -G docker -s /bin/bash -D nextflow
chown nextflow /var/run/docker.sock
# create a `nextflow` user with the provided ID

groupadd docker
useradd -u "$NXF_USRMAP" -G docker -s /bin/bash nextflow

# then change the docker socket ownership to `nextflow` user
# and change the $NXF_HOME ownership to `nextflow` user

chown nextflow /var/run/docker.sock
chown -R nextflow /.nextflow

# finally run the target command with `nextflow` user

su nextflow << EOF
[[ "$NXF_DEBUG_ENTRY" ]] && set -x
exec bash -c "$cli"
EOF

# otherwise just execute the command
else
else
exec bash -c "$cli"
fi

0 comments on commit 64a81a5

Please sign in to comment.