Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker/prod/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ services:
ports:
- ${PORT:-3000}:${PORT:-3000}
environment:
- PORT=${PORT:-3000}
- HOSTNAME=${HOSTNAME:-0.0.0.0}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/sh
set -eu

HOSTNAME=192.0.2.10 docker compose -f docker/prod/compose.yml config |
  rg -n 'HOSTNAME:'

Repository: usesend/useSend

Length of output: 193


🏁 Script executed:

#!/bin/sh
set -eu

printf 'repo files matching compose/start:\n'
git ls-files | rg '(^|/)docker/prod/compose\.yml$|(^|/)docker/start\.sh$|(^|/)compose\.yml$|(^|/)\.env' || true

printf '\nrelevant compose snippet:\n'
if [ -f docker/prod/compose.yml ]; then
  nl -ba docker/prod/compose.yml | sed -n '1,120p'
fi

printf '\nstart script references:\n'
if [ -f docker/start.sh ]; then
  nl -ba docker/start.sh | sed -n '1,200p'
fi

printf '\nHOSTNAME references:\n'
rg -n 'HOSTNAME|USESEND_HOSTNAME|HOST=' . || true

Repository: usesend/useSend

Length of output: 640


🏁 Script executed:

#!/bin/sh
set -eu

for f in docker/prod/compose.yml docker/start.sh .env.example .env.selfhost.example; do
  if [ -f "$f" ]; then
    echo "===== $f ====="
    awk '{printf "%5d\t%s\n", NR, $0}' "$f"
  fi
done

echo "===== all HOSTNAME references ====="
rg -n 'HOSTNAME|USESEND_HOSTNAME|HOST=' . || true

Repository: usesend/useSend

Length of output: 5803


🌐 Web query:

Docker Compose environment variable interpolation ${VAR:-default} host HOSTNAME environment variable documentation

💡 Result:

Docker Compose uses Bash-like syntax for variable interpolation within your compose.yaml files [1][2]. Regarding the ${VAR:-default} syntax: - This format provides a default value if the specified environment variable is unset or empty [1][2]. - Specifically, ${VAR:-default} evaluates to "default" if VAR is either unset or set to an empty string in the host environment [1][2]. - A related syntax, ${VAR-default}, evaluates to "default" only if VAR is unset; if VAR is set to an empty string, it returns the empty string rather than the default [1][2]. Regarding the HOSTNAME environment variable: - There is no specific, dedicated documentation for a reserved "HOSTNAME" environment variable that triggers special behavior in Docker Compose interpolation [3]. - You can use HOSTNAME in your interpolation expressions (e.g., image: my-app:${HOSTNAME:-default}) just like any other environment variable [1][4]. If the shell where you run docker compose has the HOSTNAME environment variable defined, its value will be used; otherwise, the default value will be substituted [1][5]. - Note that in the context of the running container itself, the hostname is defined by the container runtime (which can be configured in the compose.yaml file using the hostname attribute for the service) [6]. This is distinct from the HOSTNAME variable you might be interpolating during the compose configuration process [1][3]. To prevent interpolation for a literal string containing a dollar sign, you can use a double-dollar sign ($$) [1][2]. This tells Docker Compose to treat the sequence as a literal $ rather than an attempt to look up an environment variable [1][4].

Citations:


Use a dedicated variable for the bind address.

Docker Compose interpolates ${HOSTNAME:-0.0.0.0} from the shell or .env. A non-empty host HOSTNAME will override 0.0.0.0 and can keep the server bound to a local address. Use a dedicated variable such as USESEND_HOSTNAME.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker/prod/compose.yml` at line 53, Update the HOSTNAME environment
assignment in the Compose configuration to use the dedicated USESEND_HOSTNAME
variable, retaining 0.0.0.0 as its default so unrelated shell or .env HOSTNAME
values cannot override the bind address.

- PORT=${PORT:-3000}
- DATABASE_URL=${DATABASE_URL:?err}
- NEXTAUTH_URL=${NEXTAUTH_URL:?err}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET:?err}
Expand Down