Make config mountable #46
No reviewers
Labels
No labels
Accepted
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
help wanted
icebox
In Review
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-docker#46
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cloud-init-new"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is an adaptation on the config style. In the case the user wants to mount his own config file, he can do so. If he does not, the environment variables are used instead to create a default config.
With these changes I can fix #45
I've added a few notes for the various design choices I'd made and why I think we should keep the original behavior in some aspects, but this is a handy addition.
I wasn't going to bother making the config path dynamic within the container, but it could add flexibility for people if they need it.
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
I opted to run this as root and then a privilege de-escalation using
su -c {invocation} lbrycrd
so that it wouldn't matter what the user did to the file permissions we could re-assert them properly prior to execution.@ -9,0 +9,4 @@
# The config file does not exist in the container image. It must be mounted, or
# if not, a default config is generated using environment variables.
CONFIG_PATH=/etc/lbry/lbrycrd.conf
if [ -f "$CONFIG_PATH" ]
CONFIG_PATH=${CONFIG_PATH:-/etc/lbry/lbrycrd.conf} would let you set a default value for the config path but allow an override if there was an environment variable set.
Otherwise you're likely just going to overwrite the variable when the bash hits line 11
@ -9,0 +23,4 @@
echo "rpcbind=0.0.0.0" >> $CONFIG_PATH
#echo "bind=0.0.0.0" >> $CONFIG_PATH
fi
Gosh I forgot that I'd not done this for lbrycrd my priority at the time was Chainquery. Thank you for doing this.
So the one reason I kept this as the default behavior is when you run this script as root to launch it you gain the luxury of being able to enforce the file ownership and permissions of the config.
You then de-escalate privileges in order to run the actual application and gain the same benefits of a unpriv'd user.
I like this being an option thanks for the value add!
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
Ah that does make sense. I had a problem with it however:
I really don't know what causes it though.
@ -9,0 +9,4 @@
# The config file does not exist in the container image. It must be mounted, or
# if not, a default config is generated using environment variables.
CONFIG_PATH=/etc/lbry/lbrycrd.conf
if [ -f "$CONFIG_PATH" ]
This is the path inside the container, not outside. So I don't think it needs to be configurable, does it?
happy to leave it the way it is if I can solve the
su : must be run from a terminal
problem I have.@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
I'm glancing around for any other potentially related issues to see what solutions may be for this however if you find one before I do feel free to tweak appropriately.
I'd been going through and linting the Dockerfile and this is roughly the direction I was heading in based on your last feedback.
You'd mentioned in your last PR the preference to potentially shift to a pinned Lbrycrd version however there are fairly few excuses to have an old version of Lbry blockchain tools in operation so I added curl that pulls the latest path for the latest .zip file.
cool, multi-stage builds looks cleaner.
@EnigmaCurry I'll wait on this PR to reach stable before I merge that in unless you want to streamline mine into yours I don't require commit history so I can sleep at night.
Also the SHELL directive might solve the issue with
su -c
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
So without "USER lbrycrd" every command is run as root, which means that if they don't use start.sh, things will run as root. This is probably wrong, so it would be fixed with an ENTRYPOINT (then nothing could run except for start.sh, which does the user descalation) But, if were to use an ENRTRYPOINT, I would want to make sure that we are not hiding any of parameters from the lbrycrd binary itself. That's one of the problems with wrapper scripts..
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
This is just an idea, I haven't tested it, but can we have "USER lbrycrd" and then set the start.sh script as setuid root? That way nothing could run as root except for start.sh, which can fix permissions, then deescalate.
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
or maybe add another script to stuff called fix_permissions.sh and set that script to setuid root.
@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
So the only problem is if the config's ownership is already set to Root and it needs to be executable by the user
lbrycrd
it would not have access. You could give thelbrycrd
user the ability to usesudo
however that would be self-defeating, and at that point you might as well operate the application at the root level, to begin with within the container.@ -27,3 +27,3 @@
# USER lbrycrd
USER lbrycrd
# RUN mkdir /data
I believe that the solution will have to likely reside within aiming for an alternative to
su -c
which operates the same and doesn't necessarily require more things to be installed if at all possible. I've seen things likesu-exec
and whatnot but I've not tested them.yes I will work on it some more, but I'll open a different PR.
This PR closes #18
Pull request closed