diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..a3a0fce8
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+scripts
+test
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index e69de29b..723ef36f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea
\ No newline at end of file
diff --git a/Makefile b/Makefile
index b259902b..30627d03 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@ GOLANG_VERSION=1.12
VERSION=snapshot
DOCKER_USER=
DOCKER_PASSWORD=
+DOCKER_REPO=thecodingmachine
# generate documentation.
doc:
@@ -27,7 +28,7 @@ tests:
# build Docker image.
image:
docker build -t thecodingmachine/gotenberg:base -f build/base/Dockerfile .
- docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg VERSION=$(VERSION) -t thecodingmachine/gotenberg:$(VERSION) -f build/package/Dockerfile .
+ docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg VERSION=$(VERSION) -t $(DOCKER_REPO)/gotenberg:$(VERSION) -f build/package/Dockerfile .
# start the API using previously built Docker image.
gotenberg:
diff --git a/build/base/Dockerfile b/build/base/Dockerfile
index 102f6873..24ab4661 100644
--- a/build/base/Dockerfile
+++ b/build/base/Dockerfile
@@ -1,4 +1,4 @@
-FROM debian:9.5-slim
+FROM debian:9-slim
# |--------------------------------------------------------------------------
# | Common libraries
@@ -91,3 +91,16 @@ RUN apt-get install -y \
fonts-unfonts-core
COPY build/base/fonts.conf /etc/fonts/conf.d/100-gotenberg.conf
+
+# |--------------------------------------------------------------------------
+# | Default user
+# |--------------------------------------------------------------------------
+# |
+# | TODO find a correct description for why we're doing this.
+# |
+
+RUN groupadd --gid 1001 gotenberg \
+ && useradd --uid 1001 --gid gotenberg --shell /bin/bash --no-create-home gotenberg \
+ && mkdir /gotenberg \
+ && chown gotenberg: /gotenberg
+
diff --git a/build/docs/content/01-install.md b/build/docs/content/01-install.md
index 03585a66..0437115c 100644
--- a/build/docs/content/01-install.md
+++ b/build/docs/content/01-install.md
@@ -10,6 +10,8 @@ You may start it with:
$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:5
```
+All processes in the docker container runs as a dedicated non-root user called `gotenberg` with user id `1001` from the working dir `/gotenberg`.
+
> The API will be available at [http://localhost:3000](http://localhost:3000).
## Docker Compose
@@ -38,5 +40,12 @@ Otherwise the API will not be able to launch Google Chrome and LibreOffice (unoc
> The more resources are granted, the quicker will be the conversions.
+Also, in the deployment spec of the pod, specify the uid `1001` of the user `gotenberg`:
+```
+ securityContext:
+ privileged: false
+ runAsUser: 1001
+```
+
In the following examples, we will assume your
Gotenberg API is available at [http://localhost:3000](http://localhost:3000).
\ No newline at end of file
diff --git a/build/docs/content/03-environment-variables.md b/build/docs/content/03-environment-variables.md
index 3f081d56..685cf91c 100644
--- a/build/docs/content/03-environment-variables.md
+++ b/build/docs/content/03-environment-variables.md
@@ -8,7 +8,7 @@ You may customize the API behaviour thanks to environment variables.
In order to save some resources, the Gotenberg image accepts the environment variable `DISABLE_GOOGLE_CHROME`.
-It takes the strings `"0"` or `"1"` as value.
+It takes the strings `"0"` or `"1"` as value where `1` means `true`
> If Google Chrome is disabled, the following conversions will **not** be available anymore:
> [HTML](#html), [URL](#url) and [Markdown](#markdown)
@@ -37,12 +37,19 @@ By default, the API will add a log entry when the [healthcheck endpoint](#ping)
You may turn off this logging so as to avoid unnecessary entries in your logs with the environment variable `DISABLE_HEALTHCHECK_LOGGING`.
-This environment variable operates in the same manner as the `DISABLE_GOOGLE_CHROME` and `DISABLE_UNOCONV` variables operate in that it accepts the strings `"0"` or `"1"` as values.
-
+This environment variable operates in the same manner as the `DISABLE_GOOGLE_CHROME` and `DISABLE_UNOCONV` variables operate in that it accepts the strings `"0"` or `"1"` as values, where `1` is enabled.
## Default listen port
By default, the API will listen on port `3000`. For most use cases this is perfectly fine, but at times there may be cases where you need to change this due to port conflicts.
You may customize this port location with the environment variable `DEFAULT_LISTEN_PORT`.
-This environment variable accepts any string that can be turned into a port number (e.g., the string `"0"` up to the string `"65535"`).
\ No newline at end of file
+This environment variable accepts any string that can be turned into a port number (e.g., the string `"0"` up to the string `"65535"`).
+
+## Debug logging of process startup
+
+By default, stdout and stderr messages from the started processes are disabled.
+
+You may enable some debug logging from starting the process by setting the environment variable `DEBUG_PROCESS_STARTUP`.
+
+This environment variable operates in the same manner as the `DISABLE_GOOGLE_CHROME` and `DISABLE_UNOCONV` variables operate in that it accepts the strings `"0"` or `"1"` as values, where `1` means `true`.
\ No newline at end of file
diff --git a/build/package/Dockerfile b/build/package/Dockerfile
index f9028a72..05fa13c0 100644
--- a/build/package/Dockerfile
+++ b/build/package/Dockerfile
@@ -19,7 +19,11 @@ ENV GOOS=linux \
WORKDIR /gotenberg
# Copy our source code.
-COPY . .
+COPY internal ./internal
+COPY cmd ./cmd
+COPY go.sum go.sum
+COPY go.mod go.mod
+
# Build our binary.
RUN go build -o /gotenberg/gotenberg -ldflags "-X main.version=${VERSION}" cmd/gotenberg/main.go
@@ -37,6 +41,8 @@ LABEL authors="Julien Neuhart All processes in the docker container runs as a dedicated non-root user called The API will be available at http://localhost:3000. The more resources are granted, the quicker will be the conversions. Also, in the deployment spec of the pod, specify the uid In the following examples, we will assume your
Gotenberg API is available at http://localhost:3000. In order to save some resources, the Gotenberg image accepts the environment variable It takes the strings It takes the strings If Google Chrome is disabled, the following conversions will not be available anymore:
@@ -263,7 +272,7 @@ See the timeout section. You may turn off this logging so as to avoid unnecessary entries in your logs with the environment variable This environment variable operates in the same manner as the This environment variable operates in the same manner as the $ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:5
+gotenberg with user id 1001 from the working dir /gotenberg.
@@ -176,6 +178,13 @@ Otherwise the API will not be able to launch Google Chrome and LibreOffice (unoc
1001 of the user gotenberg: securityContext:
+ privileged: false
+ runAsUser: 1001
+
+
DISABLE_GOOGLE_CHROME."0" or "1" as value."0" or "1" as value where 1 means true
DISABLE_HEALTHCHECK_LOGGING.DISABLE_GOOGLE_CHROME and DISABLE_UNOCONV variables operate in that it accepts the strings "0" or "1" as values.DISABLE_GOOGLE_CHROME and DISABLE_UNOCONV variables operate in that it accepts the strings "0" or "1" as values, where 1 is enabled.timeout section.
This environment variable accepts any string that can be turned into a port number (e.g., the string "0" up to the string "65535").
By default, stdout and stderr messages from the started processes are disabled.
+ +You may enable some debug logging from starting the process by setting the environment variable DEBUG_PROCESS_STARTUP.
This environment variable operates in the same manner as the DISABLE_GOOGLE_CHROME and DISABLE_UNOCONV variables operate in that it accepts the strings "0" or "1" as values, where 1 means true.