diff --git a/.travis.yml b/.travis.yml index f70e2bb5..8003da9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,4 +22,4 @@ jobs: script: make tests - stage: publish if: tag IS present - script: ./scripts/publish.sh $TRAVIS_TAG $DOCKER_USER $DOCKER_PASS \ No newline at end of file + script: make publish VERSION=$TRAVIS_TAG DOCKER_USER=$DOCKER_USER DOCKER_PASSWORD=$DOCKER_PASS \ No newline at end of file diff --git a/Makefile b/Makefile index 71a96c12..8cebbf3b 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ -VERSION=snapshot GOLANG_VERSION=1.11.2 +VERSION=snapshot +DOCKER_USER= +DOCKER_PASSWORD= # generate documentation. doc: - static-docs --in build/docs --out docs --theme gotenberg --title Gotenberg --subtitle "A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF." + docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t thecodingmachine/gotenberg:docs -f build/docs/Dockerfile . + docker run --rm -it -v "$(PWD):/docs" thecodingmachine/gotenberg:docs # gofmt and goimports all go files. fmt: @@ -27,4 +30,8 @@ image: # start the API using previously built Docker image. gotenberg: - docker run -it --rm -p "3000:3000" thecodingmachine/gotenberg:$(VERSION) \ No newline at end of file + docker run -it --rm -p "3000:3000" thecodingmachine/gotenberg:$(VERSION) + +# publish Gotenberg images according to version. +publish: + ./scripts/publish.sh $(GOLANG_VERSION) $(VERSION) $(DOCKER_USER) $(DOCKER_PASSWORD) \ No newline at end of file diff --git a/build/base/Dockerfile b/build/base/Dockerfile index 86c4e0df..aa75a535 100644 --- a/build/base/Dockerfile +++ b/build/base/Dockerfile @@ -1,7 +1,5 @@ FROM debian:stretch-slim -LABEL authors="Julien Neuhart " - # |-------------------------------------------------------------------------- # | Common libraries # |-------------------------------------------------------------------------- diff --git a/build/docs/Dockerfile b/build/docs/Dockerfile new file mode 100644 index 00000000..a56df06b --- /dev/null +++ b/build/docs/Dockerfile @@ -0,0 +1,24 @@ +ARG GOLANG_VERSION + +FROM golang:${GOLANG_VERSION}-stretch + +# |-------------------------------------------------------------------------- +# | static +# |-------------------------------------------------------------------------- +# | +# | Installs the static site anti-framework – general-purpose library, +# | purpose-built commands for various domains. +# | + +RUN go get github.com/apex/static/cmd/static-docs + +# |-------------------------------------------------------------------------- +# | Final touch +# |-------------------------------------------------------------------------- +# | +# | Last instructions of this build. +# | + +WORKDIR /docs + +CMD [ "static-docs", "--in", "build/docs", "--out", "docs", "--theme", "gotenberg", "--title", "Gotenberg", "--subtitle", "A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF." ] \ No newline at end of file diff --git a/build/lint/Dockerfile b/build/lint/Dockerfile index 6a9a1935..aa39760c 100644 --- a/build/lint/Dockerfile +++ b/build/lint/Dockerfile @@ -2,8 +2,6 @@ ARG GOLANG_VERSION FROM golang:${GOLANG_VERSION}-stretch -LABEL authors="Julien Neuhart " - # |-------------------------------------------------------------------------- # | GolangCI-Lint # |-------------------------------------------------------------------------- diff --git a/build/tests/Dockerfile b/build/tests/Dockerfile index 45691739..0410c3eb 100644 --- a/build/tests/Dockerfile +++ b/build/tests/Dockerfile @@ -4,8 +4,6 @@ FROM golang:${GOLANG_VERSION}-stretch AS golang FROM thecodingmachine/gotenberg:base -LABEL authors="Julien Neuhart " - # |-------------------------------------------------------------------------- # | Common libraries # |-------------------------------------------------------------------------- diff --git a/docs/index.html b/docs/index.html index 41f64f99..2a57c794 100755 --- a/docs/index.html +++ b/docs/index.html @@ -58,6 +58,10 @@ Links +
+ +
+ @@ -157,15 +161,15 @@ which will be converted to PDF.

For instance:

<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <title>My PDF</title>
-  </head>
-  <body>
-    <h1>Hello world!</h1>
-  </body>
-</html>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>My PDF</title>
+  </head>
+  <body>
+    <h1>Hello world!</h1>
+  </body>
+</html>
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$request = new HTMLRequest($index);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$request = new HTMLRequest($index);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$header = DocumentFactory::makeFromPath('header.html', 'header.html');
-$footer = DocumentFactory::makeFromPath('footer.html', 'footer.html');
-$request = new HTMLRequest($index);
-$request->setHeader($header);
-$request->setFooter($footer);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$header = DocumentFactory::makeFromPath('header.html', 'header.html');
+$footer = DocumentFactory::makeFromPath('footer.html', 'footer.html');
+$request = new HTMLRequest($index);
+$request->setHeader($header);
+$request->setFooter($footer);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+

fonts section.

import "github.com/thecodingmachine/gotenberg/pkg"
 
-func main() {
+func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.SetAssets([]string{
+    req, _ := gotenberg.NewHTMLRequest("index.html")
+    req.SetAssets([]string{
         "font.woff",
         "img.gif",
         "style.css",
     })
     dest := "result.pdf"
-    c.Store(req, dest)
+    c.Store(req, dest)
 }
 
@@ -379,22 +383,22 @@ see to the fonts section.

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$assets = [
-    DocumentFactory::makeFromPath('style.css', 'style.css'),
-    DocumentFactory::makeFromPath('img.png', 'img.png'),
-    DocumentFactory::makeFromPath('font.woff', 'font.woff'),
-];
-$request = new HTMLRequest($index);
-$request->setAssets($assets);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$assets = [
+    DocumentFactory::makeFromPath('style.css', 'style.css'),
+    DocumentFactory::makeFromPath('img.png', 'img.png'),
+    DocumentFactory::makeFromPath('font.woff', 'font.woff'),
+];
+$request = new HTMLRequest($index);
+$request->setAssets($assets);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-use TheCodingMachine\Gotenberg\Request;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$request = new HTMLRequest($index);
-$request->setPaperSize(Request::A4);
-$request->setMargins(Request::NO_MARGINS);
-$request->setLandscape(true);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+use TheCodingMachine\Gotenberg\Request;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$request = new HTMLRequest($index);
+$request->setPaperSize(Request::A4);
+$request->setMargins(Request::NO_MARGINS);
+$request->setLandscape(true);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+
@@ -485,15 +489,15 @@ in the file index.html. This function will convert a given markdown

For instance:

<!doctype html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <title>My PDF</title>
-  </head>
-  <body>
+<html lang="en">
+  <head>
+    <meta charset="utf-8">
+    <title>My PDF</title>
+  </head>
+  <body>
     {{ toHTML .DirPath "file.md" }}
-  </body>
-</html>
+  </body>
+</html>
 

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\MarkdownRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$markdowns = [
-    DocumentFactory::makeFromPath('file.md', 'file.md'),
-];
-$request = new MarkdownRequest($index, $markdowns);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\MarkdownRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$markdowns = [
+    DocumentFactory::makeFromPath('file.md', 'file.md'),
+];
+$request = new MarkdownRequest($index, $markdowns);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+
@@ -596,11 +600,11 @@ See the scalability section to find how to mitigate t
import "github.com/thecodingmachine/gotenberg/pkg"
 
-func main() {
+func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewOfficeRequest([]string{"document.docx", "document2.docx"})
+    req, _ := gotenberg.NewOfficeRequest([]string{"document.docx", "document2.docx"})
     dest := "result.pdf"
-    c.Store(req, dest)
+    c.Store(req, dest)
 }
 
@@ -608,19 +612,19 @@ See the scalability section to find how to mitigate t PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\OfficeRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('document.docx', 'document.docx'),
-    DocumentFactory::makeFromPath('document2.docx', 'document2.docx'),
-];
-$request = new OfficeRequest($files);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\OfficeRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('document.docx', 'document.docx'),
+    DocumentFactory::makeFromPath('document2.docx', 'document2.docx'),
+];
+$request = new OfficeRequest($files);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\OfficeRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('document.docx', 'document.docx'),
-];
-$request = new OfficeRequest($files);
-$request->setPaperSize(Request::A4);
-$request->setLandscape(true);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\OfficeRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('document.docx', 'document.docx'),
+];
+$request = new OfficeRequest($files);
+$request->setPaperSize(Request::A4);
+$request->setLandscape(true);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+

PHP

-
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\MergeRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$files = [
-    DocumentFactory::makeFromPath('file.pdf', 'file.pdf'),
-    DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'),
-];
-$request = new MergeRequest($files);
-$dirPath = "/foo";
-$filename = $client->store($request, $dirPath);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\MergeRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$files = [
+    DocumentFactory::makeFromPath('file.pdf', 'file.pdf'),
+    DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'),
+];
+$request = new MergeRequest($files);
+$dirPath = "/foo";
+$filename = $client->store($request, $dirPath);
+
@@ -792,12 +796,12 @@ to given URL.

import "github.com/thecodingmachine/gotenberg/pkg"
 
-func main() {
+func main() {
     c := &gotenberg.Client{Hostname: "http://localhost:3000"}
-    req, _ := gotenberg.NewHTMLRequest("index.html")
-    req.SetWebhookURL("http://myapp.com/webhook/")
+    req, _ := gotenberg.NewHTMLRequest("index.html")
+    req.SetWebhookURL("http://myapp.com/webhook/")
     dest := "result.pdf"
-    resp, _ := c.Post(req)
+    resp, _ := c.Post(req)
 }
 
@@ -805,16 +809,16 @@ to given URL.

PHP -
use TheCodingMachine\Gotenberg\Client;
-use TheCodingMachine\Gotenberg\DocumentFactory;
-use TheCodingMachine\Gotenberg\HTMLRequest;
-
-$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
-$index = DocumentFactory::makeFromPath('index.html', 'index.html');
-$request = new HTMLRequest($index);
-$request->setWebhookURL('http://myapp.com/webhook/');
-$resp = $client->post($request);
-
+
use TheCodingMachine\Gotenberg\Client;
+use TheCodingMachine\Gotenberg\DocumentFactory;
+use TheCodingMachine\Gotenberg\HTMLRequest;
+
+$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
+$index = DocumentFactory::makeFromPath('index.html', 'index.html');
+$request = new HTMLRequest($index);
+$request->setWebhookURL('http://myapp.com/webhook/');
+$resp = $client->post($request);
+
@@ -859,6 +863,74 @@ redirect a request to a Gotenberg container according to the round-robin strateg +
+

+

ARG GOLANG_VERSION

+ +

FROM golang:${GOLANG_VERSION}-stretch

+ +

|————————————————————————–

+ +

| static

+ +

|————————————————————————–

+ +

|

+ +

| Installs the static site anti-framework – general-purpose library,

+ +

| purpose-built commands for various domains.

+ +

|

+ +

RUN go get github.com/apex/static/cmd/static-docs

+ +

|————————————————————————–

+ +

| Final touch

+ +

|————————————————————————–

+ +

|

+ +

| Last instructions of this build.

+ +

|

+ +

WORKDIR /docs

+ +

CMD [ “static-docs”, “–in”, “build/docs”, “–out”, “docs”, “–theme”, “gotenberg”, “–title”, “Gotenberg”, “–subtitle”, “A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF.” ]

+ +
+ diff --git a/scripts/publish.sh b/scripts/publish.sh index 5898fb77..0d36494f 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -2,10 +2,10 @@ set -e -GOLANG_VERSION=1.11.2 -VERSION="$1" -DOCKER_USER="$2" -DOCKER_PASSWORD="$3" +GOLANG_VERSION="$1" +VERSION="$2" +DOCKER_USER="$3" +DOCKER_PASSWORD="$4" docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"