Skip to content

fix(deploy): respect Railway $PORT in Docker entrypoint and add CI diagnostics#3

Open
Avonce901 with Copilot wants to merge 13 commits into
mainfrom
copilot/devfixdeploy
Open

fix(deploy): respect Railway $PORT in Docker entrypoint and add CI diagnostics#3
Avonce901 with Copilot wants to merge 13 commits into
mainfrom
copilot/devfixdeploy

Conversation

Copilot AI commented Nov 24, 2025

Copy link
Copy Markdown

Railway deployments were failing because the Docker entrypoint referenced a Flask app structure (src.app:app) while the actual application is Django. CI failures lacked diagnostic context.

Changes

entrypoint.sh

  • Fixed WSGI reference: src.app:appbanking.wsgi:application
  • Added cd django-banking-app to navigate to app directory
  • Added conditional Django migrations with failure tolerance
  • Respects $PORT (defaults to 5000) and WEB_CONCURRENCY (defaults to 4)

ci-cd.yml

  • Added diagnostic step displaying repo structure and checking for requirements.txt
  • Added pip caching via cache: 'pip' in setup-python action

.dockerignore (new)

  • Excludes build artifacts, logs, tests, docs, IDE configs from Docker context

Docker Testing

# Test with custom port
docker build -t bank-platform:test .
docker run -e PORT=8080 -e WEB_CONCURRENCY=2 -p 8080:8080 bank-platform:test

# Railway auto-sets PORT; verify logs show:
# "Listening at: http://0.0.0.0:$PORT"

Note: Dockerfile and Procfile already correct—both use shell-form CMD/variable substitution for $PORT.

Original prompt

Make minimal, safe changes to ensure Railway/container deployments succeed and CI shows clear failures. Changes to add in a new branch dev/fix/deploy:

  1. Update Dockerfile to respect Railway's dynamic $PORT and run an entrypoint script. Replace hard-coded gunicorn bind to 5000 with a shell-form CMD that runs entrypoint.sh which binds to ${PORT:-5000}.

  2. Add entrypoint.sh that:

    • Optionally runs migrations if a manage command or flask migration is present (tolerates failures)
    • Starts gunicorn binding to 0.0.0.0:${PORT:-5000}
    • Uses WEB_CONCURRENCY and other envs for workers
  3. Add .dockerignore to keep builds small.

  4. Update .github/workflows/ci-cd.yml to include a diagnostic step that prints repo contents and ensures requirements.txt exists, and to cache pip. This will make the CI failure visible and avoid fast-failing without logs.

  5. Ensure Procfile remains unchanged (it already uses $PORT).

All changes are additive and development-safe. Provide instructions in the PR description for how to test locally and on Railway: build/run with docker run -e PORT=8080 -p8080:8080, and how to push to Railway. Do not change application logic or models.

Files to add/modify (exact content will match previously-discussed safe templates): Dockerfile, entrypoint.sh, .dockerignore, update .github/workflows/ci-cd.yml. Commit messages should be concise: "fix(deploy): respect $PORT in Docker & add entrypoint; improve CI diagnostics".

Please create a pull request from branch dev/fix/deploy into main with the changes and include a clear PR description and how to test.

This pull request was created as a result of the following prompt from Copilot chat.

Make minimal, safe changes to ensure Railway/container deployments succeed and CI shows clear failures. Changes to add in a new branch dev/fix/deploy:

  1. Update Dockerfile to respect Railway's dynamic $PORT and run an entrypoint script. Replace hard-coded gunicorn bind to 5000 with a shell-form CMD that runs entrypoint.sh which binds to ${PORT:-5000}.

  2. Add entrypoint.sh that:

    • Optionally runs migrations if a manage command or flask migration is present (tolerates failures)
    • Starts gunicorn binding to 0.0.0.0:${PORT:-5000}
    • Uses WEB_CONCURRENCY and other envs for workers
  3. Add .dockerignore to keep builds small.

  4. Update .github/workflows/ci-cd.yml to include a diagnostic step that prints repo contents and ensures requirements.txt exists, and to cache pip. This will make the CI failure visible and avoid fast-failing without logs.

  5. Ensure Procfile remains unchanged (it already uses $PORT).

All changes are additive and development-safe. Provide instructions in the PR description for how to test locally and on Railway: build/run with docker run -e PORT=8080 -p8080:8080, and how to push to Railway. Do not change application logic or models.

Files to add/modify (exact content will match previously-discussed safe templates): Dockerfile, entrypoint.sh, .dockerignore, update .github/workflows/ci-cd.yml. Commit messages should be concise: "fix(deploy): respect $PORT in Docker & add entrypoint; improve CI diagnostics".

Please create a pull request from branch dev/fix/deploy into main with the changes and include a clear PR description and how to test.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@railway-app

railway-app Bot commented Nov 24, 2025

Copy link
Copy Markdown

🚅 Deployed to the bank-platform-pr-3 environment in beneficial-heart

Service Status Web Updated (UTC)
bank-platform ◻️ Removed (View Logs) Jan 11, 2026 at 2:50 am
web ❌ Build Failed (View Logs) Web Nov 26, 2025 at 1:37 pm

@railway-app railway-app Bot temporarily deployed to web (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:03 Destroyed
@railway-app railway-app Bot temporarily deployed to bank-platform (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:03 Destroyed
…gnostics

Co-authored-by: Avonce901 <243675487+Avonce901@users.noreply.github.com>
@railway-app railway-app Bot temporarily deployed to bank-platform (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:08 Destroyed
@railway-app railway-app Bot temporarily deployed to web (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:08 Destroyed
Co-authored-by: Avonce901 <243675487+Avonce901@users.noreply.github.com>
@railway-app railway-app Bot temporarily deployed to bank-platform (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:10 Destroyed
@railway-app railway-app Bot temporarily deployed to web (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:10 Destroyed
@railway-app railway-app Bot temporarily deployed to bank-platform (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:14 Destroyed
@railway-app railway-app Bot temporarily deployed to web (beneficial-heart / bank-platform-pr-3) November 24, 2025 10:14 Destroyed
Copilot AI changed the title [WIP] Update deployment process for Railway and CI improvements fix(deploy): respect Railway $PORT in Docker entrypoint and add CI diagnostics Nov 24, 2025
Copilot AI requested a review from Avonce901 November 24, 2025 10:16
@railway-app railway-app Bot requested a deployment to bank-platform (beneficial-heart / bank-platform-pr-3) November 26, 2025 11:50 Abandoned
@railway-app railway-app Bot temporarily deployed to bank-platform (beneficial-heart / bank-platform-pr-3) November 26, 2025 11:50 Destroyed
…thods, and webhooks

- Add StripeCustomer, PaymentMethod, StripePayment models
- Add serializers for payment data and payment intent creation
- Add StripePaymentViewSet with create_payment_intent and confirm_payment endpoints
- Configure STRIPE_SECRET_KEY, STRIPE_PUBLIC_KEY, STRIPE_WEBHOOK_SECRET settings
- Support Apple Pay, Google Pay, cards, and bank account payment methods
- Auto-credit account on successful payment with transaction record
- Register payments router in accounts URLs
… Django

- Update railway.json with Django-specific build and start commands
- Create .env.example with all required environment variables (no secrets)
- Update RAILWAY_DEPLOYMENT.md with step-by-step Railway deployment instructions
- Include Stripe webhook setup and production security checklist
- Add troubleshooting section for common deployment issues
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