Skip to content

fix: normalize line endings in docker-entrypoint.sh and update Docker… - #125

Merged
elifouts merged 1 commit into
mainfrom
Docker-Fix
Feb 27, 2026
Merged

fix: normalize line endings in docker-entrypoint.sh and update Docker…#125
elifouts merged 1 commit into
mainfrom
Docker-Fix

Conversation

@elifouts

Copy link
Copy Markdown
Collaborator

…file to handle script permissions

Copilot AI review requested due to automatic review settings February 27, 2026 08:12
@elifouts
elifouts merged commit f1b03c0 into main Feb 27, 2026
5 checks passed

Copilot AI left a comment

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.

Pull request overview

This PR aims to prevent Docker entrypoint execution issues caused by inconsistent line endings and ensure the backend container reliably runs the entrypoint script with correct permissions.

Changes:

  • Add repository-wide line-ending rules via .gitattributes (LF for shell scripts, CRLF for PowerShell).
  • Update backend Dockerfile to strip CRLF from docker-entrypoint.sh at build time and ensure it’s executable.
  • Normalize docker-entrypoint.sh content (notably removing several explanatory comments).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
backend/docker-entrypoint.sh Normalizes content; retains JWT secret generation logic but removes prior explanatory comments.
backend/Dockerfile Adds build-step normalization (CRLF removal) and chmod for the entrypoint script.
.gitattributes Enforces consistent line endings for script files across the repo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,17 +1,10 @@
#!/bin/sh
set -e

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

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

The top-of-file comments explaining why a random JWT secret is not generated by default (to preserve dev sessions) and how to enable random secret generation were removed. This behavior is non-obvious and security-sensitive; please restore that documentation (or move it to a stable docs location) so future changes don’t accidentally alter the intended semantics.

Suggested change
# JWT secret handling
# -------------------
# By default, we DO NOT generate a random DEVBITS_JWT_SECRET. When
# DEVBITS_JWT_SECRET is unset, the backend falls back to a stable built‑in
# development secret. This is intentional: it preserves dev sessions across
# container restarts so that restarting the backend does not log out all
# developers.
#
# If you want this entrypoint to generate a random secret at startup, set:
#
# DEVBITS_FORCE_RANDOM_JWT_SECRET=1
#
# When DEVBITS_FORCE_RANDOM_JWT_SECRET=1 and DEVBITS_JWT_SECRET is empty,
# we generate a random value (using openssl if available, otherwise
# /dev/urandom) and export it as DEVBITS_JWT_SECRET for this container.
#
# IMPORTANT:
# - For production, you SHOULD explicitly set a strong DEVBITS_JWT_SECRET and
# NOT rely on the built‑in development default or this random‑generation
# helper.
# - Changing how/when a random secret is generated can break expectations
# about session persistence; please update this comment if you modify the
# behavior below.

Copilot uses AI. Check for mistakes.
export DEVBITS_JWT_SECRET="$(openssl rand -hex 32)"
else
# Fallback using /dev/urandom and od
export DEVBITS_JWT_SECRET=$(head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n')

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

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

The fallback secret generation uses an unquoted command substitution. Even though the output is expected to be hex, quoting avoids any risk of word-splitting/globbing and keeps shell style consistent with the openssl branch.

Suggested change
export DEVBITS_JWT_SECRET=$(head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n')
export DEVBITS_JWT_SECRET="$(head -c 32 /dev/urandom | od -An -v -tx1 | tr -d ' \n')"

Copilot uses AI. Check for mistakes.
Comment thread backend/Dockerfile
RUN apk add --no-cache openssl
COPY docker-entrypoint.sh ./docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh
RUN sed -i 's/\r$//' ./docker-entrypoint.sh && chmod +x ./docker-entrypoint.sh

Copilot AI Feb 27, 2026

Copy link

Choose a reason for hiding this comment

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

Now that .gitattributes enforces LF for *.sh, the Docker build-time CRLF stripping via sed is likely redundant and can hide repository normalization issues. Consider relying on git normalization (and renormalizing the repo if needed) and keeping this step to just setting executable permissions, unless you have a specific non-git build context to support.

Suggested change
RUN sed -i 's/\r$//' ./docker-entrypoint.sh && chmod +x ./docker-entrypoint.sh
RUN chmod +x ./docker-entrypoint.sh

Copilot uses AI. Check for mistakes.
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.

2 participants