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

feat(container): config in-container host,port and configfile by env #47

Merged

Conversation

bonjour-py
Copy link
Contributor

feat(container): config in-container host,port and configfile by environment variables && improve entrypoint.sh

这里有一个未使用的环境变量 DEBUG 我没有动, 看原来entrypoint 的逻辑是服务器停了之后进入python。
也就是只能 docker run -it 启动,^C 中断服务器,然后才进入python 。
全文搜索了一下 好像并没有用到。有build_docker_and_test.sh使用DEBUG环境变量, 但是实际没用到后面执行python。

这里修改任何CMD进程都为pid1了,停了之后容器就退出了,没有后续了。目前将‘DEBUG=true 运行 python’ 放到运行服务器前。

目前有了 exec $* 这个功能可能用途不大了。
image

@rexzhang
Copy link
Owner

# for dev
if [ "$DEBUG" = "true" ]; then python; fi

放在最后的目的是为了解决当初开发的时候需要在容器中做调试,目的是确保服务崩溃后容器依然还在,可以进去查看(很多疑难杂症都是这么解决的).现在已经没有这个需求,可以删除,但如果保留,需要放在最后

我不确定你添加exec $*是解决什么问题?

@bonjour-py
Copy link
Contributor Author

bonjour-py commented Jun 14, 2024

exec $* 算是一个普遍的做法(nginx等,几乎有entrypoint的都添了) ,这不是必要的。
可以直接执行任何程序,比如 docker run -it image -- sh 在当前环境中进入sh。
甚至也允许 docker run -it image -- python -m asgi_webdav --host 0.0.0.0 --port 12345 --config /config.json 直接手写参数

当前的运行容器的方式是不加CMD,故添上这个既不影响当前使用,又能更灵活。

不需要的话我还是删了吧

@rexzhang
Copy link
Owner

exec $* 算是一个普遍的做法(nginx) ,这不是必要的。 可以直接执行任何程序,比如 docker run -it image -- sh 在当前环境中进入sh。 甚至也允许 docker run -it image -- python -m asgi_webdav --host 0.0.0.0 --port 12345 --config /config.json 直接手写参数

当前的运行容器的方式是不加CMD,故添上这个既不影响当前使用,又能更灵活。

不需要的话我还是删了吧

明白了,这给了高级用户更多的灵活性,应该是值得引入的.

我的担心是: exec $*可能与 DEBUG 那部分冲突?如果冲突的话,删除DEBUG部分以及相关的环境变量即可,如果需要做特别的调试可以本地临时修改entrypoint.sh来解决

普通用户>高级用户>开发者的非高频需求

@bonjour-py
Copy link
Contributor Author

我发现没有必要使用 ENTRYPOINT 这反倒复杂了, 这次的更改没有改变逻辑。(与httpd实现方式相同)

删除了DEBUG 环境变量,因为 exec su-exec runner python -m ... 把python 设为pid1, 退出后容器就退出了,不能实现退出服务器后继续运行容器

@rexzhang rexzhang merged commit 3fbbd1e into rexzhang:main Jun 14, 2024
4 checks passed
@rexzhang
Copy link
Owner

close #43

@bonjour-py bonjour-py deleted the feat/container/env-host-port-configfile branch June 14, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants