diff --git a/Makefile b/Makefile index 8fece350..5a0d93fb 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ GOLANG_VERSION=1.13 VERSION=snapshot DOCKER_USER= DOCKER_PASSWORD= -DOCKER_REPOSITORY=thecodingmachine +DOCKER_REGISTRY=thecodingmachine +GOTENBERG_USER_GID=1001 +GOTENBERG_USER_UID=1001 GOLANGCI_LINT_VERSION=1.20.1 CODE_COVERAGE=0 TINI_VERSION=0.18.0 @@ -20,12 +22,12 @@ DEFAULT_GOOGLE_CHROME_RPCC_BUFFER_SIZE=1048576 # build the base Docker image. base: - docker build -t $(DOCKER_REPOSITORY)/gotenberg:base -f build/base/Dockerfile . + docker build --build-arg GOTENBERG_USER_GID=$(GOTENBERG_USER_GID) --build-arg GOTENBERG_USER_UID=$(GOTENBERG_USER_UID) -t $(DOCKER_REGISTRY)/gotenberg:base -f build/base/Dockerfile . # build the workspace Docker image. workspace: make base - docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:workspace -f build/workspace/Dockerfile . + docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t $(DOCKER_REGISTRY)/gotenberg:workspace -f build/workspace/Dockerfile . # gofmt and goimports all go files. fmt: @@ -35,24 +37,24 @@ fmt: # run all linters. lint: make workspace - docker build --build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:lint -f build/lint/Dockerfile . - docker run --rm $(DOCKER_REPOSITORY)/gotenberg:lint + docker build --build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) -t $(DOCKER_REGISTRY)/gotenberg:lint -f build/lint/Dockerfile . + docker run --rm $(DOCKER_REGISTRY)/gotenberg:lint # run all tests. tests: make workspace - ./scripts/tests.sh $(DOCKER_REPOSITORY) $(CODE_COVERAGE) + ./scripts/tests.sh $(DOCKER_REGISTRY) $(CODE_COVERAGE) # generate documentation. doc: make workspace - docker build -t $(DOCKER_REPOSITORY)/gotenberg:docs -f build/docs/Dockerfile . - docker run --rm -it -v "$(PWD):/gotenberg/docs" $(DOCKER_REPOSITORY)/gotenberg:docs + docker build -t $(DOCKER_REGISTRY)/gotenberg:docs -f build/docs/Dockerfile . + docker run --rm -it -v "$(PWD):/gotenberg/docs" $(DOCKER_REGISTRY)/gotenberg:docs # build Gotenberg Docker image. image: make workspace - docker build --build-arg VERSION=$(VERSION) --build-arg TINI_VERSION=$(TINI_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:$(VERSION) -f build/package/Dockerfile . + docker build --build-arg VERSION=$(VERSION) --build-arg TINI_VERSION=$(TINI_VERSION) -t $(DOCKER_REGISTRY)/gotenberg:$(VERSION) -f build/package/Dockerfile . # start the API using previously built Docker image. gotenberg: @@ -61,4 +63,4 @@ gotenberg: # publish Gotenberg images according to version. publish: make workspace - ./scripts/publish.sh $(GOLANG_VERSION) $(TINI_VERSION) $(DOCKER_REPOSITORY) $(VERSION) $(DOCKER_USER) $(DOCKER_PASSWORD) \ No newline at end of file + ./scripts/publish.sh $(GOLANG_VERSION) $(TINI_VERSION) $(DOCKER_REGISTRY) $(VERSION) $(DOCKER_USER) $(DOCKER_PASSWORD) \ No newline at end of file diff --git a/build/base/Dockerfile b/build/base/Dockerfile index c40df230..31f78d84 100644 --- a/build/base/Dockerfile +++ b/build/base/Dockerfile @@ -104,7 +104,10 @@ COPY build/base/fonts.conf /etc/fonts/conf.d/100-gotenberg.conf # | non-root user. # | -RUN groupadd --gid 1001 gotenberg \ - && useradd --uid 1001 --gid gotenberg --shell /bin/bash --home /gotenberg --no-create-home gotenberg \ +ARG GOTENBERG_USER_GID=1001 +ARG GOTENBERG_USER_UID=1001 + +RUN groupadd --gid ${GOTENBERG_USER_GID} gotenberg \ + && useradd --uid ${GOTENBERG_USER_UID} --gid gotenberg --shell /bin/bash --home /gotenberg --no-create-home gotenberg \ && mkdir /gotenberg \ && chown gotenberg: /gotenberg \ No newline at end of file diff --git a/build/docs/content/01-install.md b/build/docs/content/01-install.md index ec4cdca5..7e2c4d0e 100644 --- a/build/docs/content/01-install.md +++ b/build/docs/content/01-install.md @@ -4,8 +4,6 @@ title: Install Gotenberg is shipped within a Docker image. -> It uses a dedicated non-root user called `gotenberg` with uid and gid `1001`. - You may start it with: ```bash @@ -14,6 +12,23 @@ $ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6 > The API will be available at [http://localhost:3000](http://localhost:3000). +The image uses a dedicated non-root user called `gotenberg` with uid and gid `1001`. + +If you wish to change those uid and gid, you will have to: + +* clone the project +* re-build the image +* publish the image in your own Docker registry + +For instance: + +```bash +$ git clone https://github.com/thecodingmachine/gotenberg.git +$ make publish GOTENBERG_USER_GID=your_custom_gid GOTENBERG_USER_UID=your_custom_uid DOCKER_REGISTRY=your_registry DOCKER_USER=registry_user DOCKER_PASSWORD=registry_password VERSION=6.1.0 +``` + +> `master` branch is always up-to-date with the latest version of the API. + ## Docker Compose You may also add it in your Docker Compose stack: @@ -39,7 +54,7 @@ Make sure to provide enough memory and CPU requests (for instance `512Mi` and `0 > The more resources are granted, the quicker will be the conversions. -In the deployment specification of the pod, also specify the uid `1001` of the user `gotenberg`: +In the deployment specification of the pod, also specify the uid of the user `gotenberg`: ``` securityContext: diff --git a/docs/index.html b/docs/index.html index 8aca8fff..4d130685 100755 --- a/docs/index.html +++ b/docs/index.html @@ -132,33 +132,49 @@ Install

Gotenberg is shipped within a Docker image.

-
-

It uses a dedicated non-root user called gotenberg with uid and gid 1001.

-
-

You may start it with:

-
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6
+
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6
 

The API will be available at http://localhost:3000.

+

The image uses a dedicated non-root user called gotenberg with uid and gid 1001.

+ +

If you wish to change those uid and gid, you will have to:

+ + + +

For instance:

+ +
$ git clone https://github.com/thecodingmachine/gotenberg.git
+$ make publish GOTENBERG_USER_GID=your_custom_gid GOTENBERG_USER_UID=your_custom_uid DOCKER_REGISTRY=your_registry DOCKER_USER=registry_user DOCKER_PASSWORD=registry_password VERSION=6.1.0 
+
+ +
+

master branch is always up-to-date with the latest version of the API.

+
+

Docker Compose

You may also add it in your Docker Compose stack:

-
version: '3'
+
version: '3'
 
-services:
+services:
 
   # your others services
 
-  gotenberg:
-    image: thecodingmachine/gotenberg:6
+  gotenberg:
+    image: thecodingmachine/gotenberg:6
 
@@ -177,7 +193,7 @@

The more resources are granted, the quicker will be the conversions.

-

In the deployment specification of the pod, also specify the uid 1001 of the user gotenberg:

+

In the deployment specification of the pod, also specify the uid of the user gotenberg:

securityContext:
   privileged: false
@@ -673,8 +689,8 @@ $client->store($request, $dest);
     --url http://localhost:3000/convert/html \
     --header 'Content-Type: multipart/form-data' \
     --form files=@index.html \
-    --form paperWidth=8.27 \
-    --form paperHeight=11.69 \
+    --form paperWidth=8.27 \
+    --form paperHeight=11.69 \
     --form marginTop=0 \
     --form marginBottom=0 \
     --form marginLeft=0 \
@@ -739,7 +755,7 @@ a lot on JavaScript for rendering.

--url http://localhost:3000/convert/html \ --header 'Content-Type: multipart/form-data' \ --form files=@index.html \ - --form waitDelay=5.5 \ + --form waitDelay=5.5 \ -o result.pdf
@@ -1205,7 +1221,7 @@ If unsucessful, it returns a 504 HTTP code.

--url http://localhost:3000/convert/html \ --header 'Content-Type: multipart/form-data' \ --form files=@index.html \ - --form waitTimeout=2.5 + --form waitTimeout=2.5