-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[WIP] Rootless docker #7129
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
[WIP] Rootless docker #7129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,9 @@ | ||
#!/bin/sh | ||
|
||
if [ "${USER}" != "git" ]; then | ||
# rename user | ||
sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd | ||
# switch sshd config to different user | ||
sed -i -e "s/AllowUsers git$/AllowUsers ${USER}/g" /etc/ssh/sshd_config | ||
fi | ||
|
||
if [ -z "${USER_GID}" ]; then | ||
USER_GID="`id -g ${USER}`" | ||
fi | ||
|
||
if [ -z "${USER_UID}" ]; then | ||
USER_UID="`id -u ${USER}`" | ||
fi | ||
|
||
## Change GID for USER? | ||
if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then | ||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group | ||
sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd | ||
fi | ||
|
||
## Change UID for USER? | ||
if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then | ||
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd | ||
fi | ||
|
||
for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do | ||
mkdir -p ${FOLDER} | ||
done | ||
[[ -f /usr/bin/setup ]] && source /usr/bin/setup | ||
|
||
if [ $# -gt 0 ]; then | ||
exec "$@" | ||
else | ||
exec /bin/s6-svscan /etc/s6 | ||
exec /app/gitea/gitea web | ||
fi |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,5 +1,6 @@ | ||||
#!/bin/bash | ||||
|
||||
#TODO maybe /data/git/.ssh not needed anymore | ||||
if [ ! -d /data/git/.ssh ]; then | ||||
mkdir -p /data/git/.ssh | ||||
chmod 700 /data/git/.ssh | ||||
|
@@ -26,11 +27,13 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then | |||
# Substitude the environment variables in the template | ||||
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \ | ||||
RUN_MODE=${RUN_MODE:-"dev"} \ | ||||
RUN_USER=${USER:-"git"} \ | ||||
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \ | ||||
HTTP_PORT=${HTTP_PORT:-"3000"} \ | ||||
ROOT_URL=${ROOT_URL:-""} \ | ||||
DISABLE_SSH=${DISABLE_SSH:-"false"} \ | ||||
SSH_PORT=${SSH_PORT:-"22"} \ | ||||
SSH_PORT=${SSH_PORT:-"2222"} \ | ||||
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-$SSH_PORT} \ | ||||
DB_TYPE=${DB_TYPE:-"sqlite3"} \ | ||||
DB_HOST=${DB_HOST:-"localhost:3306"} \ | ||||
DB_NAME=${DB_NAME:-"gitea"} \ | ||||
|
@@ -41,12 +44,7 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then | |||
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \ | ||||
SECRET_KEY=${SECRET_KEY:-""} \ | ||||
envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini | ||||
|
||||
chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini | ||||
fi | ||||
|
||||
# only chown if current owner is not already the gitea ${USER}. No recursive check to save time | ||||
if ! [[ $(ls -ld /data/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/gitea; fi | ||||
if ! [[ $(ls -ld /app/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/gitea; fi | ||||
if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi | ||||
chmod 0755 /data/gitea /app/gitea /data/git | ||||
chmod 0755 /data/gitea /data/git | ||||
#chmod 0755 /app/gitea | ||||
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.
Suggested change
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. Yes and I don't think it is a problem. I will recheck but that a good point that the process inside the containre couldn't change content inside /app/gitea |
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.
If docker user internal SSH server, it's not needed
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.
While it is not needed for the single process setup, removing it would break existing setups.
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.
@das7pad yes but it is for the setup part so if we don't need it anymore we don't need to create it if it doesn't exist.
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.
For folks who backup the entire /data/git directory it is not a problem. But for those who just backup non-generated files, read only the repositories directory, the .ssh directory would be missing upon restore.
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.
But the internal sshserver doesn't use the .ssh directory...
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.
I was thinking about the third example in #7129 (review).
I know that the files in the .ssh directory are only needed to get the spawned sshd-childs talk with the correct gitea instance.