mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
Fix docker restart (#670)
<!--
Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md
-->
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fix Docker restart by processing environment variables in a temporary
working directory in `entrypoint.sh`.
>
> - **Behavior**:
> - Create `/tmp/processed` directory in `entrypoint.sh` to copy and
process files for environment variable replacement.
> - Replace environment variable sentinels in files within
`/tmp/processed` instead of `/app`.
> - Change working directory to `/tmp/processed` before starting backend
and dashboard.
> - **Misc**:
> - Add logging for file copying to working directory in
`entrypoint.sh`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for bb6ff27e90. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
parent
5dc13defac
commit
0b443a056d
@ -51,8 +51,16 @@ fi
|
||||
|
||||
# ============= ENV VARS =============
|
||||
|
||||
# Find all files in /app/apps that contain a STACK_ENV_VAR_SENTINEL and extract the unique sentinel strings.
|
||||
unhandled_sentinels=$(find /app/apps -type f -exec grep -l "STACK_ENV_VAR_SENTINEL" {} + | \
|
||||
# Create a working directory for our processed files
|
||||
# This is necessary because we need to replace the env vars in all files and we might want to run the seed script multiple times with different env vars.
|
||||
WORK_DIR="/tmp/processed"
|
||||
mkdir -p "$WORK_DIR"
|
||||
|
||||
echo "Copying files to working directory..."
|
||||
cp -r /app/. "$WORK_DIR"/.
|
||||
|
||||
# Find all files in the working directory that contain a STACK_ENV_VAR_SENTINEL and extract the unique sentinel strings.
|
||||
unhandled_sentinels=$(find "$WORK_DIR/apps" -type f -exec grep -l "STACK_ENV_VAR_SENTINEL" {} + | \
|
||||
xargs grep -h "STACK_ENV_VAR_SENTINEL" | \
|
||||
grep -o "STACK_ENV_VAR_SENTINEL[A-Z_]*" | \
|
||||
sort -u | grep -v "^STACK_ENV_VAR_SENTINEL$")
|
||||
@ -79,13 +87,14 @@ for sentinel in $unhandled_sentinels; do
|
||||
# the chosen delimiter and the '&' (which has special meaning in sed replacements).
|
||||
escaped_value=$(printf '%s\n' "$value" | sed -e 's/\\/\\\\/g' -e "s/[${delimiter}&]/\\\\&/g")
|
||||
|
||||
# Now replace the sentinel with the (properly escaped) value in all files.
|
||||
find /app/apps -type f -exec sed -i "s${delimiter}${escaped_sentinel}${delimiter}${escaped_value}${delimiter}g" {} +
|
||||
# Now replace the sentinel with the (properly escaped) value in all files in the working directory.
|
||||
find $WORK_DIR/apps -type f -exec sed -i "s${delimiter}${escaped_sentinel}${delimiter}${escaped_value}${delimiter}g" {} +
|
||||
done
|
||||
|
||||
# ============= START BACKEND AND DASHBOARD =============
|
||||
|
||||
echo "Starting backend on port $BACKEND_PORT..."
|
||||
cd "$WORK_DIR"
|
||||
PORT=$BACKEND_PORT HOSTNAME=0.0.0.0 node apps/backend/server.js &
|
||||
|
||||
echo "Starting dashboard on port $DASHBOARD_PORT..."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user