Go Docker Alpine

Product: pdftron-go

Product Version: github.com/pdftron/pdftron-go/v2

Please give a brief summary of your issue: Build go project in Alpine linux

Please describe your issue and provide steps to reproduce it:
What is the instruction to build Apryse server SDK in Go project using alpine image?

Please provide a link to a minimal sample where the issue is reproducible:
This is my docker file

FROM golang:1.23-alpine

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN go build -o server .

EXPOSE 8080

CMD ["./server"]

I’m getting this error:

=> ERROR [6/6] RUN go build -o server .                                                                                                                                          0.6s
------                                                                                                                                                                                 
 > [6/6] RUN go build -o server .:                                                                                                                                                     
0.568 package pdf-annotates-location                                                                                                                                                   
0.568   imports pdf-annotates-location/pdf
0.568   imports github.com/pdftron/pdftron-go/v2: build constraints exclude all Go files in /go/pkg/mod/github.com/pdftron/pdftron-go/v2@v2.3.3
------
Dockerfile:10
--------------------
   8 |     COPY . .
   9 |     
  10 | >>> RUN go build -o server .
  11 |     
  12 |     EXPOSE 8080
--------------------
ERROR: failed to solve: process "/bin/sh -c go build -o server ." did not complete successfully: exit code: 1

imports github.com/pdftron/pdftron-go/v2: build constraints exclude all Go files in /go/pkg/mod/github.com/pdftron/pdftron-go/v2@v2.3.3

The “build constraints exclude …” can be several issues but I think the most common is that the system file permissions are not allowing the user to access the go pkg folder “/go/pkg/mod/github.com/pdftron/pdftron-go/v2@v2.3.3”. You can see the same result testing in a local Linux instance running the Apryse SDK GO examples by running:

go install github.com/pdftron/pdftron-go/v2@2.3.3

And running the included tests as a non root user. You will need to adjust the permissions for your specific user.