Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version updates & dockerization #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
docker-compose.yml
.git*
log/*
tmp/*
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-1.9.3-p448
ruby-2.4.2
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
156 changes: 89 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -77,7 +96,7 @@ PLATFORMS
ruby

DEPENDENCIES
json (= 1.7.7)
json
liquid
markdown
pdf-forms
Expand All @@ -90,3 +109,6 @@ DEPENDENCIES
sinatra
thin
webrat

BUNDLED WITH
1.16.0
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 22 additions & 11 deletions views/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<form method="post" action ="/fill">

<!-- A standard, fillable field, simply pass the field name -->
<label>First Name: <input type="text" name="first_name" /><label>

<!-- A non-fillable field for which we pass coordinates -->
<label>Last Name: <input type="text" name="100,100,1" /><label>

<input type="submit" value="Submit" />

</form>

```

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`)
Expand All @@ -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.

Expand All @@ -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`.
Expand All @@ -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.

Expand Down