-
Notifications
You must be signed in to change notification settings - Fork 789
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
Use the server config instead of env variables for the API port and the server hostname #488
Conversation
src/shadowbox/docker/run_action.sh
Outdated
readonly STATE_DIR=$OUTLINE_DIR/persisted-state | ||
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json | ||
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json" | ||
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG | ||
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}" | ||
|
||
# TODO: mount a folder rather than individual files. | ||
declare -a docker_bindings=( | ||
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json |
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.
Let's use shadowbox_config.json instead of config.json. It's less confusing.
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.
In fact, this line is not needed if you are mounting the state dir. Both config files go there.
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 don't understand why we can remove this line, the config isn't in the persisted-state 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.
See what we do in production:
outline-server/src/server_manager/install_scripts/install_server.sh
Lines 262 to 272 in 47446d4
declare -a docker_shadowbox_flags=( | |
--name shadowbox --restart=always --net=host | |
-v "${STATE_DIR}:${STATE_DIR}" | |
-e "SB_STATE_DIR=${STATE_DIR}" | |
-e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}" | |
-e "SB_API_PORT=${API_PORT}" | |
-e "SB_API_PREFIX=${SB_API_PREFIX}" | |
-e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}" | |
-e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}" | |
-e "SB_METRICS_URL=${SB_METRICS_URL:-}" | |
-e "SB_DEFAULT_SERVER_NAME=${SB_DEFAULT_SERVER_NAME:-}" |
We actually mount the state dir. The config files are in it. Let's reproduce that, so it's closer to production and easier to understand. Using a different structure and file names for dev is confusing.
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.
Responded to comments. From offline discussion, also removed install script changes until after these changes get released. I messe dup Git royally though so definitely needs a close eye of review
src/shadowbox/docker/run_action.sh
Outdated
readonly STATE_DIR=$OUTLINE_DIR/persisted-state | ||
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json | ||
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json" | ||
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG | ||
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}" | ||
|
||
# TODO: mount a folder rather than individual files. | ||
declare -a docker_bindings=( | ||
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json |
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 don't understand why we can remove this line, the config isn't in the persisted-state directory.
src/shadowbox/server/main.ts
Outdated
|
||
const DEFAULT_PORT = 8081; | ||
const apiPortNumber = Number(process.env.SB_API_PORT || DEFAULT_PORT); | ||
const apiPortNumber = Number(serverConfig.data().apiPort || process.env.SB_API_PORT || DEFAULT_PORT); |
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.
Done. Also edited the error message to show the user where the config is located so it's easier for them to edit the config.
Friendly ping :) |
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.
Looks good. One minor comment below.
I'm sorry for the delay!
src/shadowbox/docker/run_action.sh
Outdated
readonly STATE_DIR=$OUTLINE_DIR/persisted-state | ||
readonly STATE_CONFIG=$STATE_DIR/shadowbox_server_config.json | ||
mkdir -p $STATE_DIR && touch "$OUTLINE_DIR/config.json" | ||
[[ -e $STATE_CONFIG ]] || echo "{\"hostname\":\"127.0.0.1\", \"apiPort\":2357}" > $STATE_CONFIG | ||
source $ROOT_DIR/src/shadowbox/scripts/make_test_certificate.sh "${OUTLINE_DIR}" | ||
|
||
# TODO: mount a folder rather than individual files. | ||
declare -a docker_bindings=( | ||
-v "$OUTLINE_DIR/config.json":/root/shadowbox/shadowbox_config.json |
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.
See what we do in production:
outline-server/src/server_manager/install_scripts/install_server.sh
Lines 262 to 272 in 47446d4
declare -a docker_shadowbox_flags=( | |
--name shadowbox --restart=always --net=host | |
-v "${STATE_DIR}:${STATE_DIR}" | |
-e "SB_STATE_DIR=${STATE_DIR}" | |
-e "SB_PUBLIC_IP=${PUBLIC_HOSTNAME}" | |
-e "SB_API_PORT=${API_PORT}" | |
-e "SB_API_PREFIX=${SB_API_PREFIX}" | |
-e "SB_CERTIFICATE_FILE=${SB_CERTIFICATE_FILE}" | |
-e "SB_PRIVATE_KEY_FILE=${SB_PRIVATE_KEY_FILE}" | |
-e "SB_METRICS_URL=${SB_METRICS_URL:-}" | |
-e "SB_DEFAULT_SERVER_NAME=${SB_DEFAULT_SERVER_NAME:-}" |
We actually mount the state dir. The config files are in it. Let's reproduce that, so it's closer to production and easier to understand. Using a different structure and file names for dev is confusing.
715f288
to
1cd28e4
Compare
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.
Please double check carefully. I had to re do a lot of steps here as my git history got screwed up at some point.
At some point down the line I royally screwed up my git history and reverted a bunch of changes. I'm not sure what or when, so I `git reset --hard 1cd28e4` and tried to redo my past responses to comments from there.
8c2f8c3
to
2a61138
Compare
No description provided.