File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM golang:latest as build-env
2
+
3
+ RUN apt-get update -qq
4
+ # Install gotesseract system dependecies
5
+ RUN apt-get install -y -qq libtesseract-dev libleptonica-dev
6
+ ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata/
7
+
8
+ RUN apt-get install -y -qq \
9
+ tesseract-ocr-eng \
10
+ tesseract-ocr-deu \
11
+ tesseract-ocr-jpn
12
+
13
+ # All these steps will be cached
14
+ RUN mkdir /app-server
15
+ WORKDIR /app-server
16
+ # COPY go.mod and go.sum files to the workspace
17
+ COPY go.mod .
18
+ COPY go.sum .
19
+ # Get dependancies - will also be cached if we won't change mod/sum
20
+ RUN go mod download
21
+
22
+ # COPY the source code as the last step
23
+ COPY . .
24
+ ARG CI_COMMIT_SHA
25
+ ARG CI_COMMIT_REF_NAME
26
+ # RUN MKDIR -p dist
27
+ # Build the binary
28
+ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.gitCommit=$CI_COMMIT_SHA -X main.gitRef=$CI_COMMIT_REF_NAME" -a -installsuffix cgo -o ./app ./cmd/server/main.go
29
+ RUN ./app -version
30
+
31
+ # <- Second step to build minimal image
32
+ # FROM scratch
33
+ FROM debian
34
+
35
+ RUN apt-get update
36
+ RUN apt-get install -y -qq libtesseract-dev libleptonica-dev
37
+ ENV TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata/
38
+ RUN apt-get install -y -qq \
39
+ tesseract-ocr-eng \
40
+ tesseract-ocr-deu \
41
+ tesseract-ocr-jpn
42
+
43
+ WORKDIR /app-server
44
+
45
+ COPY --from=build-env /app-server/ /app-server
46
+
47
+ ENTRYPOINT ["/app-server/app" ]
48
+ EXPOSE 3333
49
+ EXPOSE 4444
You can’t perform that action at this time.
0 commit comments