Skip to content

Commit

Permalink
chore: explicit the Gotenberg version
Browse files Browse the repository at this point in the history
  • Loading branch information
gulien committed Apr 17, 2024
1 parent ec37697 commit 910d699
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ help: ## Show the help
it: build build-tests ## Initialize the development environment

GOLANG_VERSION=1.22
GOTENBERG_VERSION=8.4.0
APP_NAME=app
APP_VERSION=snapshot
APP_AUTHOR=app-author
Expand All @@ -17,36 +18,38 @@ GOLANGCI_LINT_VERSION=v1.56.2 # See https://github.com/golangci/golangci-lint/re
build: ## Build the Gotenberg's Docker image
docker build \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg GOTENBERG_VERSION=$(GOTENBERG_VERSION) \
--build-arg APP_NAME=$(APP_NAME) \
--build-arg APP_VERSION=$(APP_VERSION) \
--build-arg APP_AUTHOR=$(APP_AUTHOR) \
--build-arg APP_REPOSITORY=$(APP_REPOSITORY) \
-t $(DOCKER_REPOSITORY)/gotenberg:8-$(APP_NAME)-$(APP_VERSION) \
-t $(DOCKER_REPOSITORY)/gotenberg:$(GOTENBERG_VERSION)-$(APP_NAME)-$(APP_VERSION) \
-f build/Dockerfile .

.PHONY: build-tests
build-tests: ## Build the tests' Docker image
docker build \
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \
--build-arg DOCKER_REPOSITORY=$(DOCKER_REPOSITORY) \
--build-arg GOTENBERG_VERSION=$(GOTENBERG_VERSION) \
--build-arg APP_NAME=$(APP_NAME) \
--build-arg APP_VERSION=$(APP_VERSION) \
--build-arg GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION) \
-t $(DOCKER_REPOSITORY)/gotenberg:8-$(APP_NAME)-$(APP_VERSION)-tests \
-t $(DOCKER_REPOSITORY)/gotenberg:$(GOTENBERG_VERSION)-$(APP_NAME)-$(APP_VERSION)-tests \
-f test/Dockerfile .

.PHONY: tests
tests: ## Start the testing environment
docker run --rm -it \
-v $(PWD):/tests \
$(DOCKER_REPOSITORY)/gotenberg:8-$(APP_NAME)-$(APP_VERSION)-tests \
$(DOCKER_REPOSITORY)/gotenberg:$(GOTENBERG_VERSION)-$(APP_NAME)-$(APP_VERSION)-tests \
bash

.PHONY: tests-once
tests-once: ## Run the tests once (prefer the "tests" command while developing)
docker run --rm \
-v $(PWD):/tests \
$(DOCKER_REPOSITORY)/gotenberg:8-$(APP_NAME)-$(APP_VERSION)-tests \
$(DOCKER_REPOSITORY)/gotenberg:$(GOTENBERG_VERSION)-$(APP_NAME)-$(APP_VERSION)-tests \
gotest

# go install mvdan.cc/gofumpt@latest
Expand Down
9 changes: 6 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ARG GOLANG_VERSION
ARG GOTENBERG_VERSION

FROM golang:$GOLANG_VERSION AS builder

Expand All @@ -18,21 +19,23 @@ COPY cmd ./cmd
COPY pkg ./pkg

# Build the binary.
ARG GOTENBERG_VERSION
ARG APP_NAME
ARG APP_VERSION

RUN go build -o gotenberg -ldflags "-X 'github.com/gotenberg/gotenberg/v8/cmd.Version=8-$APP_NAME-$APP_VERSION'" cmd/app/main.go
RUN go build -o gotenberg -ldflags "-X 'github.com/gotenberg/gotenberg/v8/cmd.Version=$GOTENBERG_VERSION-$APP_NAME-$APP_VERSION'" cmd/app/main.go

FROM gotenberg/gotenberg:8
FROM gotenberg/gotenberg:$GOTENBERG_VERSION

ARG GOTENBERG_VERSION
ARG APP_AUTHOR
ARG APP_REPOSITORY
ARG APP_NAME
ARG APP_VERSION

LABEL org.opencontainers.image.title="Gotenberg $APP_NAME" \
org.opencontainers.image.description="A Docker-powered stateless API for PDF files." \
org.opencontainers.image.version="$GOTENBERG_VERSION-$APP_VERSION" \
org.opencontainers.image.version="$GOTENBERG_VERSION-$APP_NAME-$APP_VERSION" \
org.opencontainers.image.authors="$APP_AUTHOR" \
org.opencontainers.image.source="$APP_REPOSITORY"

Expand Down
3 changes: 2 additions & 1 deletion test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ARG GOLANG_VERSION
ARG DOCKER_REPOSITORY
ARG GOTENBERG_VERSION
ARG APP_NAME
ARG APP_VERSION
ARG GOLANGCI_LINT_VERSION
Expand All @@ -8,7 +9,7 @@ FROM golang:$GOLANG_VERSION-bullseye as golang

# We're extending the Gotenberg's Docker image because our code relies on external
# dependencies like Google Chrome, LibreOffice, etc.
FROM $DOCKER_REPOSITORY/gotenberg:8-$APP_NAME-$APP_VERSION
FROM $DOCKER_REPOSITORY/gotenberg:$GOTENBERG_VERSION-$APP_NAME-$APP_VERSION

USER root

Expand Down

0 comments on commit 910d699

Please sign in to comment.