Skip to content

Commit f499fbd

Browse files
committed
Add entrypoint script with migrations and seed
1 parent 0abaab7 commit f499fbd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

backend/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ RUN pip install --no-cache-dir -r requirements.txt
1616
# Copy application code
1717
COPY . .
1818

19+
# Make entrypoint executable
20+
RUN chmod +x entrypoint.sh
21+
1922
# Create non-root user
2023
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
2124
USER appuser
2225

2326
# Expose port (Railway uses dynamic PORT)
2427
EXPOSE 8000
2528

26-
# Default command (Railway overrides via railway.toml)
27-
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
29+
# Run entrypoint script (migrations, seed, then server)
30+
CMD ["./entrypoint.sh"]

backend/entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo "Running database migrations..."
5+
alembic upgrade head
6+
7+
echo "Seeding database..."
8+
python scripts/seed_data.py || echo "Seed already exists or failed (continuing...)"
9+
10+
echo "Starting server..."
11+
exec uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8000}

0 commit comments

Comments
 (0)