diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ac2d59 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +Dockerfile +docker-compose.yml +.git* +log/* +tmp/* diff --git a/.ruby-version b/.ruby-version index 8e17352..951d42f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-1.9.3-p448 +ruby-2.4.2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3e85e6a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM ruby:2.5-alpine + +WORKDIR /app + +COPY . /app + +RUN apk update && apk upgrade \ + && apk add pdftk \ + && gem install bundler \ + && apk add git openssh-client pdftk musl-dev make g++ \ + && bundle install + +EXPOSE 4567 diff --git a/Gemfile b/Gemfile index 4110e8d..26c53be 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem 'thin' gem 'liquid' gem 'pdf-forms' gem 'prawn' -gem 'json', "1.7.7" +gem 'json' gem 'markdown' group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0cda910..51f89cb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,73 +1,92 @@ GEM remote: https://rubygems.org/ specs: - Ascii85 (1.0.2) - afm (0.2.0) - coderay (1.0.9) - daemons (1.1.9) - diff-lcs (1.2.4) - eventmachine (1.0.3) - hashery (2.1.0) - json (1.7.7) - kramdown (1.1.0) - liquid (2.5.0) - logutils (0.6.0) - markdown (1.1.1) - kramdown (>= 1.0.2) - props (>= 1.0.0) - textutils (>= 0.6.4) - method_source (0.8.1) - mini_portile (0.5.1) - multi_json (1.7.7) - nokogiri (1.6.0) - mini_portile (~> 0.5.0) - pdf-forms (0.5.5) - pdf-reader (1.3.3) - Ascii85 (~> 1.0.0) - afm (~> 0.2.0) - hashery (~> 2.0) - ruby-rc4 - ttfunk - prawn (0.12.0) - pdf-reader (>= 0.9.0) - ttfunk (~> 1.0.2) - props (1.0.0) - pry (0.9.12.2) - coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.4) - rack (1.5.2) - rack-protection (1.5.0) + activesupport (5.2.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + cliver (0.3.2) + coderay (1.1.2) + concurrent-ruby (1.0.5) + daemons (1.2.6) + diff-lcs (1.3) + docile (1.3.0) + eventmachine (1.2.5) + i18n (1.0.0) + concurrent-ruby (~> 1.0) + iniparser (0.1.0) + json (2.1.0) + kramdown (1.16.2) + liquid (4.0.0) + logutils (0.6.1) + markdown (1.2.0) + kramdown (>= 1.5.0) + props (>= 1.1.2) + textutils (>= 0.10.0) + method_source (0.9.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + mustermann (1.0.2) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + pdf-core (0.7.0) + pdf-forms (1.1.1) + cliver (~> 0.3.2) + safe_shell (>= 1.0.3, < 2.0) + prawn (2.2.2) + pdf-core (~> 0.7.0) + ttfunk (~> 1.5) + props (1.2.0) + iniparser (>= 0.1.0) + pry (0.11.3) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + rack (2.0.4) + rack-protection (2.0.1) rack - rack-test (0.6.2) - rack (>= 1.0) - rake (10.1.0) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.2) - rspec-expectations (2.14.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.1) - ruby-rc4 (0.1.5) - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - sinatra (1.4.3) - rack (~> 1.4) - rack-protection (~> 1.4) - tilt (~> 1.3, >= 1.3.4) - slop (3.4.5) - textutils (0.6.6) - logutils (~> 0.5) - thin (1.5.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - tilt (1.4.1) - ttfunk (1.0.3) + rack-test (1.0.0) + rack (>= 1.0, < 3) + rake (12.3.1) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-mocks (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.1) + rubyzip (1.2.1) + safe_shell (1.1.0) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + sinatra (2.0.1) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.1) + tilt (~> 2.0) + textutils (1.4.0) + activesupport + logutils (>= 0.6.1) + props (>= 1.1.2) + rubyzip (>= 1.0.0) + thin (1.7.2) + daemons (~> 1.0, >= 1.0.9) + eventmachine (~> 1.0, >= 1.0.4) + rack (>= 1, < 3) + thread_safe (0.3.6) + tilt (2.0.8) + ttfunk (1.5.1) + tzinfo (1.2.5) + thread_safe (~> 0.1) webrat (0.7.3) nokogiri (>= 1.2.0) rack (>= 1.0) @@ -77,7 +96,7 @@ PLATFORMS ruby DEPENDENCIES - json (= 1.7.7) + json liquid markdown pdf-forms @@ -90,3 +109,6 @@ DEPENDENCIES sinatra thin webrat + +BUNDLED WITH + 1.16.0 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..42bf3c9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" +services: + pdf_filler: + build: . + image: pdf-filler + volumes: + - .:/app + ports: + - "4567:4567" + command: ruby /app/app.rb -o '0.0.0.0' + tty: true + stdin_open: true diff --git a/views/index.md b/views/index.md index 1255a65..0b5f77a 100755 --- a/views/index.md +++ b/views/index.md @@ -61,31 +61,34 @@ Structuring the HTML Form Data can be submitted programmatically (e.g. via an API) or as a standard web-based form. For example, to structure an HTML form, you may do so as follows: -```html +```html
- + ``` Requirements ------------ - * Latest stable version of Ruby (+ the Bundler gem) * PDFtk +OR + +* Docker + Setting up ---------- - +_(If running in Docker, skip to 'Running' section)_ 1. Install the latest version of Ruby if not already installed (`$ \curl -L https://get.rvm.io | bash -s stable --ruby`) 2. Install [PDFtk](http://www.pdflabs.com/docs/install-pdftk/) 3. Install bundler if not already installed (`gem install bundler`) @@ -95,8 +98,16 @@ Setting up Running ------- +#### Local +To run, simply run the command `ruby app.rb` from the project's directory. + +#### Docker +``` +$ docker-compose build +$ docker-compose up +``` -To run, simply run the command `ruby app.rb` from the project's directory. The service will be exposed on port `4567` by default. +For both methods the service will be exposed on port `4567` by default. You can freely use PDF Filler as a web service. But if you'd like to grab the source code and host it locally, it's actually pretty easy. @@ -109,7 +120,7 @@ Deploying PDF Filler is simple to deploy as a backend service on your server. Follow the instructions here: http://www.kalzumeus.com/2010/01/15/deploying-sinatra-on-ubuntu-in-which-i-employ-a-secretary/ as an example of how to deploy and set up the app as a backend service on your machine. There is a file called daemon.rb that is part of the app for this purpose. -Hosting +Hosting ------ The app is designed to be hosted on hosting services like heroku. If using Heroku, be sure to select the "Bamboo" build (which comes compiled with pdftk) and set an environment config for `PATH_TO_PDFTK` to `/usr/bin/pdftk`. @@ -123,7 +134,7 @@ Examples Contributing ------------ -Anyone is encouraged to contribute to the project by [forking](https://help.github.com/articles/fork-a-repo) and submitting a pull request. (If you are new to GitHub, you might start with a [basic tutorial](https://help.github.com/articles/set-up-git).) +Anyone is encouraged to contribute to the project by [forking](https://help.github.com/articles/fork-a-repo) and submitting a pull request. (If you are new to GitHub, you might start with a [basic tutorial](https://help.github.com/articles/set-up-git).) By contributing to this project, you grant a world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license to all users under the terms of the [MIT](http://opensource.org/licenses/mit-license.php) License.