-
Notifications
You must be signed in to change notification settings - Fork 10
Change to common user gid and uid for dy-static-file-server* & nginx replacement #140
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
Changes from all commits
30a85b4
982e59f
94f3da0
e4b32dd
d375e0c
0a39e03
b5d6417
2e09a4b
eb2b46b
b14d607
16f4876
9fd40a9
6fb76a8
2309309
245d123
92cae0e
c78a71e
5f7cb8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.7 | ||
2.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
#!/bin/sh | ||
set -o errexit | ||
set -o nounset | ||
|
||
IFS=$(printf '\n\t') | ||
# This entrypoint script: | ||
# | ||
# - Executes *inside* of the container upon start as --user [default root] | ||
# - Notice that the container *starts* as --user [default root] but | ||
# *runs* as non-root user [$SC_USER_NAME] | ||
# | ||
echo Entrypoint for stage "${SC_BUILD_TARGET}" ... | ||
echo User : "$(id "$(whoami)")" | ||
echo Workdir : "$(pwd)" | ||
|
||
|
||
# adapt to be compatible for legacy boot mode | ||
if [ -n "$SIMCORE_NODE_BASEPATH" ]; then | ||
echo "Boot mode: LEGACY" | ||
echo "Creating ${INPUT_FOLDER} and ${OUTPUT_FOLDER}" | ||
mkdir -p "${INPUT_FOLDER}" | ||
mkdir -p "${OUTPUT_FOLDER}" | ||
echo "SERVER_ROOT: ${SERVER_ROOT}" | ||
echo "SIMCORE_NODE_BASEPATH: ${SIMCORE_NODE_BASEPATH}" | ||
echo "Creating ${SERVER_ROOT}${SIMCORE_NODE_BASEPATH} and changin ownership to $SC_USER_NAME" | ||
mkdir -p "${SERVER_ROOT}${SIMCORE_NODE_BASEPATH}" | ||
chown -R "$SC_USER_NAME" "${SERVER_ROOT}${SIMCORE_NODE_BASEPATH}" | ||
else | ||
echo "Boot mode: DYNAMIC-SIDECAR" | ||
fi | ||
|
||
|
||
# expect input/output folders to be mounted | ||
#TODO: determine if legacy boot more and based on that do stuff like creating | ||
stat "${INPUT_FOLDER}" > /dev/null 2>&1 || \ | ||
(echo "ERROR: You must mount '${INPUT_FOLDER}' to deduce user and group ids" && exit 1) | ||
stat "${OUTPUT_FOLDER}" > /dev/null 2>&1 || \ | ||
(echo "ERROR: You must mount '${OUTPUT_FOLDER}' to deduce user and group ids" && exit 1) | ||
|
||
# NOTE: expects docker run ... -v /path/to/input/folder:${INPUT_FOLDER} | ||
# check input/output folders are owned by the same user | ||
if [ "$(stat -c %u "${INPUT_FOLDER}")" -ne "$(stat -c %u "${OUTPUT_FOLDER}")" ] | ||
then | ||
echo "ERROR: '${INPUT_FOLDER}' and '${OUTPUT_FOLDER}' have different user id's. not allowed" && exit 1 | ||
fi | ||
# check input/outputfolders are owned by the same group | ||
if [ "$(stat -c %g "${INPUT_FOLDER}")" -ne "$(stat -c %g "${OUTPUT_FOLDER}")" ] | ||
then | ||
echo "ERROR: '${INPUT_FOLDER}' and '${OUTPUT_FOLDER}' have different group id's. not allowed" && exit 1 | ||
fi | ||
|
||
echo "listing inputs folder" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MINOR: not important in here but just FYI, in osparc-simcore images we use always prefix for the echo's so they can be easily parse by graylog |
||
ls -lah "${INPUT_FOLDER}" | ||
echo "listing outputs folder" | ||
ls -lah "${OUTPUT_FOLDER}" | ||
|
||
echo "setting correct user id/group id..." | ||
HOST_USERID=$(stat -c %u "${INPUT_FOLDER}") | ||
HOST_GROUPID=$(stat -c %g "${INPUT_FOLDER}") | ||
CONT_GROUPNAME=$(getent group "${HOST_GROUPID}" | cut -d: -f1) | ||
if [ "$HOST_USERID" -eq 0 ] | ||
then | ||
echo "Warning: Folder mounted owned by root user... adding $SC_USER_NAME to root..." | ||
addgroup "$SC_USER_NAME" root | ||
else | ||
echo "Folder mounted owned by user $HOST_USERID:$HOST_GROUPID-'$CONT_GROUPNAME'..." | ||
# take host's credentials in $SC_USER_NAME | ||
if [ -z "$CONT_GROUPNAME" ] | ||
then | ||
echo "Creating new group my$SC_USER_NAME" | ||
CONT_GROUPNAME=my$SC_USER_NAME | ||
addgroup -g "$HOST_GROUPID" "$CONT_GROUPNAME" | ||
else | ||
echo "group already exists" | ||
fi | ||
|
||
echo "changing $SC_USER_NAME $SC_USER_ID:$SC_USER_ID to $HOST_USERID:$HOST_GROUPID" | ||
# in alpine there is no such thing as usermod... so we delete the user and re-create it as part of $CONT_GROUPNAME | ||
deluser "$SC_USER_NAME" > /dev/null 2>&1 | ||
adduser -u "$HOST_USERID" -G "$CONT_GROUPNAME" -D -s /bin/sh "$SC_USER_NAME" | ||
|
||
echo "Changing group properties of files around from $SC_USER_ID to group $CONT_GROUPNAME" | ||
find / -path /var/log/nginx -prune -o -group "$SC_USER_ID" -print | ||
find / -path /var/log/nginx -prune -o -group "$SC_USER_ID" -exec chgrp -h "$CONT_GROUPNAME" {} \; | ||
# change user property of files already around | ||
echo "Changing ownership properties of files around from $SC_USER_ID to group $CONT_GROUPNAME" | ||
find / -path /var/log/nginx -prune -o -user "$SC_USER_ID" -exec chown -h "$SC_USER_NAME" {} \; | ||
find / -path /var/log/nginx -prune -o -user "$SC_USER_ID" -print | ||
fi | ||
|
||
echo "Starting $* ..." | ||
echo " $SC_USER_NAME rights : $(id "$SC_USER_NAME")" | ||
echo " local dir : $(ls -al)" | ||
echo " input dir : $(ls -al "${INPUT_FOLDER}")" | ||
echo " output dir : $(ls -al "${OUTPUT_FOLDER}")" | ||
|
||
|
||
# from original etrypoint | ||
set -e | ||
|
||
# Check if incomming command contains flags. | ||
if [ "${1#-}" != "$1" ]; then | ||
set -- static-web-server "$@" | ||
fi | ||
|
||
su-exec "$SC_USER_NAME" "$@" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: dy-static-file-server-dynamic-sidecar-compose-spec | |
key: simcore/services/dynamic/dy-static-file-server-dynamic-sidecar-compose-spec | ||
type: dynamic | ||
integration-version: 1.0.0 | ||
version: 1.0.7 | ||
version: 2.0.0 | ||
description: Modern test dynamic service providing a docker-compose specification file (with dynamic sidecar and compose-spec). Changes to the inputs will be forwarded to the outputs. The /workdir/generated-data directory is populated if no content is present. | ||
contact: [email protected] | ||
authors: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: dy-static-file-server-dynamic-sidecar | |
key: simcore/services/dynamic/dy-static-file-server-dynamic-sidecar | ||
type: dynamic | ||
integration-version: 1.0.0 | ||
version: 1.0.7 | ||
version: 2.0.0 | ||
description: Modern test dynamic service (with dynamic sidecar). Changes to the inputs will be forwarded to the outputs. The /workdir/generated-data directory is populated if no content is present. | ||
contact: [email protected] | ||
authors: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: dy-static-file-server | |
key: simcore/services/dynamic/dy-static-file-server | ||
type: dynamic | ||
integration-version: 1.0.0 | ||
version: 1.0.7 | ||
version: 2.0.0 | ||
description: Legacy test dynamic service (starts using original director-v0). The /workdir/generated-data directory is populated if no content is present. | ||
contact: [email protected] | ||
authors: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: would that not mean a new Major version? or at least minor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it more, I'd go for a major change here! going for
2.0.0
Base image and a bit of how everything behaves has been changed. Also trying to figure out compatibility with
director-v0