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
18 changes: 7 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,23 @@ ENV FORGE_DEBUG_LOGGING=${ARG_DEBUG_LOGGING}
# Install system dependencies including PostgreSQL client and gosu for user privilege management
RUN apt-get update && apt-get install -y \
postgresql-client \
gosu \
&& rm -rf /var/lib/apt/lists/*

# Create logs directory
RUN mkdir -p /app/logs
RUN mkdir -p /app/logs && \
chown -R nobody:nogroup /app/logs && \
chmod -R 777 /app/logs

# Copy project files
COPY . .

# Copy entrypoint script and make it executable
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

# Install dependencies using pip
RUN pip install -e ".[dev]"
RUN pip install -e .

# Switch to non-root user for security
USER nobody

# Expose port
EXPOSE 8000

# Set the entrypoint to our script
ENTRYPOINT ["docker-entrypoint.sh"]

# Run the application (this command is passed to the entrypoint)
CMD ["gunicorn", "app.main:app", "-k", "uvicorn.workers.UvicornWorker", "--workers", "10", "--bind", "0.0.0.0:8000"]
6 changes: 5 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ set -e
chown -R nobody:nogroup /app/logs

# Run Alembic migrations
alembic upgrade head
echo "Running database migrations..."
if ! alembic upgrade head; then
echo "⚠️ Warning: Alembic migration failed. Continuing without shutdown."
fi

# Use gosu to drop from root to the 'nobody' user and run the main command
exec gosu nobody "$@"

Loading