-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
81 lines (66 loc) · 2.51 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -----------
# Build stage
# -----------
FROM debian:11 AS build
LABEL stage=builder
LABEL org.opencontainers.image.authors="[email protected]"
#install prereqs
WORKDIR /
RUN apt-get update -qqy && DEBIAN_FRONTEND=noninteractive apt-get install -y \
wget bash apt-transport-https
RUN wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN rm packages-microsoft-prod.deb
RUN apt-get update -qqy && apt-get install -y dotnet-sdk-6.0
RUN eval apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#get OcrWaterMeter and publish it
COPY OcrWaterMeter /OcrWaterMeter
WORKDIR /OcrWaterMeter
RUN dotnet publish ./Server/OcrWaterMeter.Server.csproj -c Release -p:PublishProfile=DefaultPublish
# -----------
# Final stage
# -----------
FROM debian:11
LABEL org.opencontainers.image.authors="[email protected]"
#dotnet config
ENV ASPNETCORE_URLS="http://+:5000"
ENV DATADIR="/data"
#User creation
RUN groupadd -g 1010 -r ocrwatermeter && useradd --no-log-init -u 1010 -r -g ocrwatermeter ocrwatermeter
#default datadir
RUN mkdir /data && chown -R ocrwatermeter:ocrwatermeter /data
VOLUME [ "/data" ]
#install prereqs
RUN apt-get update -qqy && DEBIAN_FRONTEND=noninteractive apt-get install -y \
wget apt-transport-https
RUN wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN rm packages-microsoft-prod.deb
RUN apt-get update -qqy && apt-get install -y aspnetcore-runtime-6.0 libleptonica-dev libtesseract-dev libc6-dev curl
RUN eval apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#copy OcrWaterMeter files
WORKDIR /OcrWaterMeter
COPY --from=build /OcrWaterMeter/Server/bin/Release/net6.0/publish /OcrWaterMeter
RUN chmod +x OcrWaterMeter.Server
#versioning
ARG BUILDNUMBER
ENV BUILDNUMBER=$BUILDNUMBER
ARG BUILDID
ENV BUILDID=$BUILDID
ARG SOURCE_COMMIT
ENV SOURCE_COMMIT=$SOURCE_COMMIT
ARG BUILDNODE
ENV BUILDNODE=$BUILDNODE
#fix libraries
WORKDIR /OcrWaterMeter/x64
RUN ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 liblept.so.5
RUN ln -s /usr/lib/x86_64-linux-gnu/libleptonica.so libleptonica-1.80.0.so
RUN ln -s /usr/lib/x86_64-linux-gnu/libtesseract.so libtesseract41.so
#Expose the port used
EXPOSE 5000/tcp
#User
USER ocrwatermeter
# run
WORKDIR /OcrWaterMeter
CMD [ "/bin/sh", "-c", "/OcrWaterMeter/OcrWaterMeter.Server" ]
HEALTHCHECK --retries=3 --timeout=5s CMD curl --fail http://localhost:5000/healthz || exit