Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JAQA20/LaComanda/llms.txt

Use this file to discover all available pages before exploring further.

Railway.app is a cloud platform that can host La Comanda with zero infrastructure management. Railway detects the project’s Dockerfile automatically, builds the image on every push to your connected GitHub repository, and injects the runtime $PORT variable that La Comanda’s start.sh script uses to configure Apache — no manual server setup required.

Prerequisites

Before deploying, make sure you have:
  • A free or paid Railway account
  • Your La Comanda source code pushed to a GitHub repository
  • (Optional) The Railway CLI installed for managing environment variables and running one-off commands from the terminal

Deployment Steps

1
Connect Your Repository
2
  • Log in to Railway and click New Project.
  • Select Deploy from GitHub repo and authorise Railway to access your GitHub account.
  • Choose the repository that contains your La Comanda source code.
  • Railway will detect the Dockerfile at the repo root and queue an initial build.
  • 3
    Add a MySQL Service
    4
  • Inside your Railway project, click + New and choose Database → MySQL.
  • Railway provisions a MySQL 8.0 instance and exposes connection variables automatically.
  • Open the MySQL service’s Variables tab and note the values for MYSQL_HOST, MYSQL_PORT, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD — you will map these to La Comanda’s expected variable names in the next step.
  • 5
    Set Environment Variables
    6
    Navigate to your web service’s Variables tab and add every variable listed in .env.example. Pay close attention to the database connection variables, which must point to the Railway MySQL service rather than the local db container:
    7
    VariableValueDB_HOSTInternal Railway MySQL hostname (copy from MySQL service variables)DB_PORT3306 (Railway internal port)DB_NAMEYour Railway MySQL database nameDB_USERYour Railway MySQL usernameDB_PASSWORDYour Railway MySQL passwordAPP_URLYour Railway public URL, e.g. https://yourapp.up.railway.appBASE_URL/APP_ENVproduction
    8
    Never use the seeded test passwords in production. Update all user passwords in the database and in your Railway environment variables after deployment.
    9
    Deploy
    10
    Once environment variables are saved, Railway triggers a new build (or you can click Deploy manually). The build process:
    11
  • Builds the Docker image from your Dockerfile.
  • Starts the container using railway/start.sh as the entrypoint.
  • start.sh reads the $PORT variable injected by Railway, writes the correct Listen directive into Apache’s configuration, and starts apache2-foreground.
  • 12
    Your app will be live at the Railway-generated URL within a few minutes.
    13
    Import the Schema
    14
    The Railway MySQL service starts empty — you need to load the schema manually:
    15
    Option A — Railway CLI:
    16
    # Forward the Railway MySQL port to your local machine
    railway connect mysql
    
    # In another terminal, import the schema
    mysql -h 127.0.0.1 -P <local-port> -u <user> -p <database> < db/la_comanda.sql
    
    17
    Option B — MySQL client with public URL:
    18
    mysql -h <RAILWAY_MYSQL_HOST> -P <RAILWAY_MYSQL_PORT> \
      -u <DB_USER> -p <DB_NAME> < db/la_comanda.sql
    
    19
    Option C — Database GUI (TablePlus, DBeaver, etc.): use the connection details from the Railway MySQL service variables to connect, then run or import db/la_comanda.sql.

    Environment Variables for Railway

    The table below highlights the key differences between your local .env and the values required on Railway:
    VariableLocal valueRailway value
    DB_HOSTdb (Docker service name)Internal Railway MySQL hostname
    DB_PORT33063306 (internal)
    PORT(not set — defaults to 80)Injected automatically by Railway — do not set manually
    APP_URLhttp://localhost:8080https://yourapp.up.railway.app
    BASE_URL//
    APP_ENVlocalproduction
    The railway.json file sets restartPolicyType to ON_FAILURE with maxRetries: 10, so Railway will automatically attempt to restart the container if it crashes during startup or runtime.

    How Port Configuration Works

    Railway dynamically assigns a port to each deployment and passes it as the $PORT environment variable. La Comanda handles this through railway/start.sh:
    # railway/start.sh (simplified flow)
    
    # Read $PORT from the environment, default to 80 if not set
    PORT="${PORT:-80}"
    
    # Update Apache's Listen directive
    sed -i "s/Listen 80/Listen ${PORT}/" /etc/apache2/ports.conf
    
    # Update the VirtualHost port in the default site config
    sed -i "s/<VirtualHost \*:80>/<VirtualHost *:${PORT}>/" \
      /etc/apache2/sites-available/000-default.conf
    
    # Disable threaded MPMs, enable prefork (required for mod_php)
    a2dismod mpm_event mpm_worker || true
    a2enmod mpm_prefork
    
    # Start Apache in the foreground (keeps the container alive)
    apache2-foreground
    
    This approach means the same Docker image works in both environments without modification:
    Environment$PORT valueApache listens on
    Local Docker Compose(unset — defaults to 80)80 (mapped to host 8080)
    RailwayInjected dynamically (e.g. 8080, 3000)Whatever Railway assigns
    If you ever need to verify the active Apache configuration inside a running Railway container, use the Railway CLI: railway run apache2ctl -S

    Build docs developers (and LLMs) love