Skip to content

Commit 6253017

Browse files
committed
added docker file
1 parent 27e5e6a commit 6253017

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

0 commit comments

Comments
 (0)