Skip to content
Merged
Show file tree
Hide file tree
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
46 changes: 46 additions & 0 deletions Dockerfile.railway
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
FROM python:3.11-slim

ARG GIT_COMMIT_SHA
ENV GIT_COMMIT_SHA=$GIT_COMMIT_SHA

# Install system dependencies needed for building the C extension
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
build-essential \
&& rm -rf /var/lib/apt/lists/*

# Upgrade pip (optional but often recommended)
RUN pip install --no-cache-dir --upgrade pip

# Install crcmod, which will compile the C extension if a compiler is available
RUN pip install --no-cache-dir crcmod

# (Optionally) remove build-essential to keep image small, if you no longer need it:
# RUN apt-get remove -y build-essential && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

RUN pip install gsutil

WORKDIR /app

# copy the dependencies file to the working directory
COPY requirements.txt .
COPY railway_deploy.sh .

# install dependencies
RUN pip install -r requirements.txt --no-cache-dir

# copy the content of the local directory to the working directory
COPY app app
COPY static static

# Set PYTHONPATH to include the project root
ENV PYTHONPATH=/app

# Expose the port the app runs on
EXPOSE 8000

# Make script executable
RUN chmod +x railway_deploy.sh

CMD ["./railway_deploy.sh"]
30 changes: 30 additions & 0 deletions railway_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail

# railway_deploy.sh
# On Railway (or any host), clone the private tenants repo and build/run its Docker image.
# Requires: GITHUB_TOKEN (or GITHUB_ACCESS_TOKEN) set in the environment.

REPO_URL="https://github.com/voteagora/tenants"
CLONE_DIR="${CLONE_DIR:-./tenants}"

# Prefer GITHUB_TOKEN; fall back to GITHUB_ACCESS_TOKEN
GITHUB_TOKEN="${GITHUB_TOKEN:-${GITHUB_ACCESS_TOKEN:-}}"
if [[ -z "${GITHUB_TOKEN}" ]]; then
echo "Error: GITHUB_TOKEN or GITHUB_ACCESS_TOKEN must be set to clone the private repo." >&2
exit 1
fi

# Clone using token (no prompt). Use a shallow clone for speed.
CLONE_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/voteagora/tenants.git"
if [[ -d "${CLONE_DIR}" ]]; then
echo "Directory ${CLONE_DIR} already exists; pulling latest..."
git -C "${CLONE_DIR}" pull --ff-only || true
else
echo "Cloning ${REPO_URL} into ${CLONE_DIR}..."
git clone --depth 1 "${CLONE_URL}" "${CLONE_DIR}"
fi

python -m app.cli sync-from-gcs data

sanic app.server --host=0.0.0.0 --port=8000