diff options
author | Edgars <Edgars+GitHub@gaitenis.id.lv> | 2021-10-06 10:52:09 +0300 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2021-10-28 22:45:11 +0530 |
commit | 085916c33d28408739e0cf886d2ae4316cb92ee4 (patch) | |
tree | cb0feae9431ab9fac0beb5324ce323672bb177db | |
parent | Merge pull request #48 from k0staa/master (diff) | |
download | ferdium-server-085916c33d28408739e0cf886d2ae4316cb92ee4.tar.gz ferdium-server-085916c33d28408739e0cf886d2ae4316cb92ee4.tar.zst ferdium-server-085916c33d28408739e0cf886d2ae4316cb92ee4.zip |
Fix `docker/entrypoint.sh`
`docker/entrypoint.sh` was updated to fix errors that results in a
container that runs on a locally built Ferdi Server image.
Fixes that were made:
- shebang was changed to `#!/bin/sh` as the Node Alpine image does not
have `bash`, therefore the container cannot start because of the error
"/usr/local/bin/docker-entrypoint.sh: exec: line 8: /entrypoint.sh:
not found";
- `if` condition was updated to make it more portable so it works with
non-Bash shells;
- `su-exec` command was updated to remove the redundant `#!/bin/bash`
from the end of the line as it was causing the error "Error: Cannot
find module '/app/server.js#!/bin/bash'".
Additional code optimization changes:
- tabs were replaced with spaces;
- optimizations to avoid code duplication:
- new variable `key_file` was added to hold the path to the Ferdi app
key file;
- the function `print_app_key_message` was added to print the
informational message about the app key.
-rwxr-xr-x | docker/entrypoint.sh | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 2a91839..2e58abc 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | 2 | ||
3 | cat << EOL | 3 | cat << EOL |
4 | ------------------------------------- | 4 | ------------------------------------- |
@@ -14,21 +14,31 @@ Support our Open Collective at: | |||
14 | https://opencollective.com/getferdi/ | 14 | https://opencollective.com/getferdi/ |
15 | EOL | 15 | EOL |
16 | 16 | ||
17 | key_file="${DATA_DIR}/FERDI_APP_KEY.txt" | ||
18 | |||
19 | print_app_key_message() { | ||
20 | app_key=$1 | ||
21 | printf '**** App key is %s. ' ${app_key} | ||
22 | printf 'You can modify `%s` to update the app key ****\n' ${key_file} | ||
23 | } | ||
24 | |||
17 | # Create APP key if needed | 25 | # Create APP key if needed |
18 | if [[ -z ${APP_KEY} && ! -f "${DATA_DIR}/FERDI_APP_KEY.txt" ]]; then | 26 | if [ -z ${APP_KEY} ] && [ ! -f ${key_file} ] |
19 | echo "**** Generating Ferdi-server app key for first run ****" | 27 | then |
20 | adonis key:generate | 28 | echo '**** Generating Ferdi-server app key for first run ****' |
21 | APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) | 29 | adonis key:generate |
22 | echo "${APP_KEY}" > "${DATA_DIR}/FERDI_APP_KEY.txt" | 30 | APP_KEY=$(grep APP_KEY .env | cut -d '=' -f2) |
23 | echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" | 31 | echo ${APP_KEY} > ${key_file} |
24 | else APP_KEY=$(cat "${DATA_DIR}/FERDI_APP_KEY.txt") | 32 | print_app_key_message ${APP_KEY} |
25 | echo "**** App Key set to $APP_KEY you can modify FERDI_APP_KEY.txt to update your key ****" | 33 | else |
34 | APP_KEY=$(cat ${key_file}) | ||
35 | print_app_key_message ${APP_KEY} | ||
26 | fi | 36 | fi |
27 | 37 | ||
28 | export APP_KEY | 38 | export APP_KEY |
29 | 39 | ||
30 | node ace migration:run --force | 40 | node ace migration:run --force |
31 | 41 | ||
32 | chown -R "${PUID:-1000}":"${PGID:-1000}" "$DATA_DIR" /app | 42 | chown -R "${PUID:-1000}":"${PGID:-1000}" "${DATA_DIR}" /app |
33 | 43 | ||
34 | su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js#!/bin/bash | 44 | su-exec "${PUID:-1000}":"${PGID:-1000}" node server.js |