diff --git a/Makefile b/Makefile index 30627d03..0af767b0 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,12 @@ GOLANG_VERSION=1.12 VERSION=snapshot DOCKER_USER= DOCKER_PASSWORD= -DOCKER_REPO=thecodingmachine +DOCKER_REPOSITORY=thecodingmachine # generate documentation. doc: - 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 + docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:docs -f build/docs/Dockerfile . + docker run --rm -it -v "$(PWD):/docs" $(DOCKER_REPOSITORY)/gotenberg:docs # gofmt and goimports all go files. fmt: @@ -16,23 +16,23 @@ fmt: # run all linters. lint: - docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t thecodingmachine/gotenberg:lint -f build/lint/Dockerfile . - docker run --rm -it -v "$(PWD):/lint" thecodingmachine/gotenberg:lint + docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:lint -f build/lint/Dockerfile . + docker run --rm -it -v "$(PWD):/lint" $(DOCKER_REPOSITORY)/gotenberg:lint # run all tests. tests: - docker build -t thecodingmachine/gotenberg:base -f build/base/Dockerfile . - docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t thecodingmachine/gotenberg:tests -f build/tests/Dockerfile . - docker run --rm -it -v "$(PWD):/tests" thecodingmachine/gotenberg:tests + docker build -t $(DOCKER_REPOSITORY)/gotenberg:base -f build/base/Dockerfile . + docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t $(DOCKER_REPOSITORY)/gotenberg:tests -f build/tests/Dockerfile . + docker run --rm -it -v "$(PWD):/tests" $(DOCKER_REPOSITORY)/gotenberg:tests # build Docker image. image: - docker build -t thecodingmachine/gotenberg:base -f build/base/Dockerfile . + docker build -t $(DOCKER_REPOSITORY)/gotenberg:base -f build/base/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: - docker run -it --rm -p "3000:3000" thecodingmachine/gotenberg:$(VERSION) + docker run -it --rm -e DEBUG_PROCESS_STARTUP=1 -p "3000:3000" $(DOCKER_REPOSITORY)/gotenberg:$(VERSION) # publish Gotenberg images according to version. publish: diff --git a/build/base/Dockerfile b/build/base/Dockerfile index 24ab4661..d6cbbb64 100644 --- a/build/base/Dockerfile +++ b/build/base/Dockerfile @@ -96,11 +96,11 @@ 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. +# | All processes in the Docker container will run as a dedicated +# | non-root user. # | 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 0437115c..cc29d1ba 100644 --- a/build/docs/content/01-install.md +++ b/build/docs/content/01-install.md @@ -10,7 +10,7 @@ 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`. +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). @@ -40,11 +40,11 @@ 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`: +Also, in the deployment spec of the pod, specify the uid `1001` of the user `gotenberg`: ``` - securityContext: - privileged: false - runAsUser: 1001 +securityContext: + privileged: false + runAsUser: 1001 ``` In the following examples, we will assume your diff --git a/build/docs/content/03-environment-variables.md b/build/docs/content/03-environment-variables.md index 685cf91c..70653291 100644 --- a/build/docs/content/03-environment-variables.md +++ b/build/docs/content/03-environment-variables.md @@ -48,7 +48,7 @@ This environment variable accepts any string that can be turned into a port numb ## Debug logging of process startup -By default, stdout and stderr messages from the started processes are disabled. +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`. diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 05fa13c0..532a55a2 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -24,7 +24,6 @@ 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 diff --git a/cmd/gotenberg/main.go b/cmd/gotenberg/main.go index dae9192e..9d6a3088 100644 --- a/cmd/gotenberg/main.go +++ b/cmd/gotenberg/main.go @@ -50,7 +50,9 @@ func mustParseEnvVar() *api.Options { } opts.DefaultListenPort = v } - //checkBoolEnv is a convenience function for reading an env var with a bool value where `1` is true and `0` is false + // checkBoolEnv is a convenience function for reading + // an env var with a bool value where + // `1` is true and `0` is false. checkBoolEnv := func(name string) bool { if v, ok := os.LookupEnv(name); ok { if v != "1" && v != "0" { diff --git a/docs/index.html b/docs/index.html index fa8df116..6e1a1677 100755 --- a/docs/index.html +++ b/docs/index.html @@ -139,7 +139,7 @@
$ 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.
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.
@@ -180,9 +180,9 @@ Otherwise the API will not be able to launch Google Chrome and LibreOffice (unocAlso, in the deployment spec of the pod, specify the uid
-1001of the usergotenberg:securityContext: - privileged: false - runAsUser: 1001 +securityContext: + privileged: false + runAsUser: 1001In the following examples, we will assume your @@ -288,7 +288,7 @@ See the timeout section.
Debug logging of process startup -By default, stdout and stderr messages from the started processes are disabled.
+By default,
stdoutandstderrmessages from the started processes are disabled.You may enable some debug logging from starting the process by setting the environment variable
diff --git a/internal/pkg/pm2/chrome.go b/internal/pkg/pm2/chrome.go index 105c76cc..bad71c3e 100644 --- a/internal/pkg/pm2/chrome.go +++ b/internal/pkg/pm2/chrome.go @@ -7,15 +7,13 @@ import ( "github.com/mafredri/cdp/devtool" ) -const ( - warmupTime = 10 * time.Second -) +const warmupTime = 10 * time.Second type chrome struct { manager *processManager } -// NewChrome retruns a Google Chrome +// NewChrome returns a Google Chrome // headless process. func NewChrome(debug bool) Process { return &chrome{ diff --git a/internal/pkg/pm2/pm2.go b/internal/pkg/pm2/pm2.go index 167b3e0d..fe2498d6 100644 --- a/internal/pkg/pm2/pm2.go +++ b/internal/pkg/pm2/pm2.go @@ -87,11 +87,11 @@ func (m *processManager) pm2(p Process, cmdName string) error { if m.verbose { processStdErr, err := cmd.StderrPipe() if err != nil { - return fmt.Errorf("failed getting stderr from '%s': %v", p.Fullname(), err) + return fmt.Errorf("failed getting stderr from %s: %s", p.Fullname(), err) } processStdOut, err := cmd.StdoutPipe() if err != nil { - return fmt.Errorf("failed getting stdout from '%s': %v", p.Fullname(), err) + return fmt.Errorf("failed getting stdout from %s: %s", p.Fullname(), err) } readFromPipe := func(name string, reader io.ReadCloser) { r := bufio.NewReader(reader) @@ -100,12 +100,12 @@ func (m *processManager) pm2(p Process, cmdName string) error { line, _, err := r.ReadLine() if err != nil { if err != io.EOF { - m.notifyf("error reading from %v for process '%v'", name, p.Fullname()) + m.notifyf("error reading from %s for process %s", name, p.Fullname()) } break } if len(line) != 0 { - m.notifyf("%v %v: %s", p.name(), name, string(line)) + m.notifyf("%s %s: %s", p.name(), name, string(line)) } } } diff --git a/internal/pkg/pm2/unoconv.go b/internal/pkg/pm2/unoconv.go index 7c4fa13e..e7274f69 100644 --- a/internal/pkg/pm2/unoconv.go +++ b/internal/pkg/pm2/unoconv.go @@ -4,7 +4,7 @@ type unoconv struct { manager *processManager } -// NewUnoconv retruns a unoconv listener +// NewUnoconv returns a unoconv listener // process. func NewUnoconv(debug bool) Process { return &unoconv{DEBUG_PROCESS_STARTUP.