Prerequisites
Before setting up the PDF Form Parser application, ensure you have the following installed:- Ruby 3.4.1 - The application uses Ruby 3.4.1 as specified in the Dockerfile
- PostgreSQL 9.3+ - Required for the database
- Node.js and npm - For JavaScript asset management
- pdftk - PDF toolkit for form processing
- libvips - Image processing library for Active Storage variants
System Dependencies
The application requires several system packages. On Debian/Ubuntu:Installing Dependencies
1. Clone the Repository
2. Install Ruby Gems
The application uses Bundler to manage Ruby dependencies:Key Gems
The application includes these essential gems:- rails 8.0.2 - Web framework
- pg - PostgreSQL adapter
- devise 4.9 - User authentication
- pundit - Authorization
- pdf-forms - Reading PDF form fields
- hexapdf 0.36 - PDF digital signatures (PAdES)
- combine_pdf - Merging PDFs
- prawn - PDF generation
- aws-sdk-s3 - S3-compatible storage
- image_processing - Image transformations
- solid_cache, solid_queue, solid_cable - Rails 8 solid libraries
- kaminari - Pagination
- tailwindcss-rails - CSS framework
3. Install JavaScript Dependencies
Environment Configuration
Development Environment
Create a.env file in the root directory for development. The application uses the dotenv-rails gem to load environment variables.
The
dotenv-rails gem is only available in development and test environments. In production, set environment variables through your hosting platform.Production Environment Variables
For production deployment, configure these environment variables:Running the Application
Development Server
Start the development server using the Rails server:http://localhost:3000.
Console Access
Access the Rails console for debugging and data manipulation:Running Tests
Execute the test suite:Docker Setup
The application includes a production-ready Dockerfile for containerized deployment.Building the Image
Running with Docker
The Dockerfile uses a multi-stage build to minimize image size. The final image runs as a non-root user for security.
Deployment with Kamal
The application is configured for deployment using Kamal:Configuration Files
config/application.rb- Main application configurationconfig/environments/development.rb- Development settingsconfig/environments/production.rb- Production settingsconfig/database.yml- Database configurationconfig/storage.yml- Active Storage configurationconfig/initializers/devise.rb- Authentication configuration
Next Steps
After completing the initial setup:- Configure the database and run migrations
- Set up Active Storage for file uploads
- Configure authentication and create your first user
Troubleshooting
Missing pdftk
If you encounter errors aboutpdftk not being found:
libvips Errors
For image processing issues:Bundle Install Failures
Ifbundle install fails with pg gem errors: