-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
96 lines (79 loc) · 2.73 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -----------
# Build stage
# -----------
FROM debian:11 AS build
LABEL stage=builder
LABEL org.opencontainers.image.authors="[email protected]"
#args
ARG NETEVENTNETVER
ENV NETEVENTNETVER=$NETEVENTNETVER
#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-7.0 python3 python3-pip wget
RUN pip install lastversion
RUN eval apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#get wait-for
RUN wget -q $(lastversion https://github.com/eficode/wait-for --format assets)
#get NetEvent and publish it
COPY NetEvent /NetEvent
COPY .sonarlint /.sonarlint
WORKDIR /NetEvent
RUN dotnet publish ./Server/NetEvent.Server.csproj -c Release -p:PublishProfile=DefaultPublish -p:Version=$NETEVENTNETVER
# -----------
# Final stage
# -----------
FROM debian:11
LABEL org.opencontainers.image.authors="[email protected]"
#dotnet config
ENV ASPNETCORE_URLS="http://+:5000"
ENV DBProvider="sqlite"
ENV DBName="/data/netevent.db"
ENV DBServer=""
ENV DBPort=""
ENV DBUser=""
ENV DBPassword=""
ENV TZ="Europe/Berlin"
#User creation
RUN groupadd -g 1010 -r NetEvent && useradd --create-home --no-log-init -u 1010 -r -g NetEvent NetEvent
#default datadir
RUN mkdir /data && chown -R NetEvent:NetEvent /data
VOLUME [ "/data" ]
#container scripts
COPY docker/start-container /usr/local/bin/start-container
COPY --from=build /wait-for /usr/local/bin/wait-for.sh
RUN chmod +x /usr/local/bin/start-container
RUN chmod +x /usr/local/bin/wait-for.sh
#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-7.0 netcat curl
RUN eval apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
#copy NetEvent files
WORKDIR /NetEvent
COPY --from=build /NetEvent/Server/bin/Release/net7.0/publish /NetEvent
RUN chmod +x NetEvent.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
#Expose the port used
EXPOSE 5000/tcp
#User
USER NetEvent
# run
WORKDIR /NetEvent
CMD [ "/bin/sh", "-c", "start-container" ]
HEALTHCHECK --retries=3 --timeout=5s CMD curl --fail http://localhost:5000/healthz || exit