Skip to content
Merged
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
14 changes: 8 additions & 6 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ COPY . .
# Create repos directory for cloning
RUN mkdir -p repos

# Expose port
# Expose the default port (informational; Railway injects its own $PORT at runtime)
EXPOSE 8000

# Health check
# Health check hits whatever port the app bound to, so it tracks $PORT not a hardcoded 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health').read()" || exit 1
CMD python -c "import os,urllib.request; p=os.environ.get('PORT','8000'); urllib.request.urlopen('http://localhost:'+p+'/health').read()" || exit 1

# Run with uvicorn (proxy-headers enabled for rate limiting behind reverse proxy)
# Set FORWARDED_ALLOW_IPS env var in production to your proxy's IP range
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers"]
# Bind Railway's dynamic $PORT (fallback 8000 for local/compose). The platform healthcheck
# queries $PORT, so hardcoding 8000 here makes the deploy fail "service unavailable".
# exec keeps uvicorn as PID 1 so it gets SIGTERM for graceful shutdown.
# proxy-headers for rate limiting behind the reverse proxy (set FORWARDED_ALLOW_IPS in prod).
CMD exec uvicorn main:app --host 0.0.0.0 --port ${PORT:-8000} --proxy-headers
Loading