-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.example
60 lines (44 loc) · 1.86 KB
/
Dockerfile.example
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
# ------ STAGE 1 (build container) ---------------------
# Source image to start with
FROM mono:6.8.0 as build-env
# create working directory for build
ADD . /build
WORKDIR /build
# install git and nuget
RUN apt update && apt install -y git nuget
# Create DLL M2Mqtt.Net.dll via GitHub Repo (all in one container):
# (*** ONLY works with the mono:6.8.0 image - not with mono:6.8.0-slim ***)
# - download MQTT client library
# - change directory
# - build M2Mqtt.Net.dll and save output files in dir "build" of container
RUN git clone https://github.com/eclipse/paho.mqtt.m2mqtt \
&& cd paho.mqtt.m2mqtt/M2Mqtt \
&& msbuild M2Mqtt.Net.csproj /p:Configuration=Release /p:OutputPath=/build
# *** second possibility to get M2Mqtt.Net.dll ***
# Create DLL M2Mqtt.Net.dll via NuGet package:
# - install nuget package in directory "build"
# - copy M2Mqtt.Net.dll into directory "build"
#RUN nuget install M2Mqtt -Version 4.3.0 -OutputDirectory /build
#RUN cd M2Mqtt.4.3.0.0/lib/net45 && cp M2Mqtt.Net.dll /build
# Create DLL Newtonsoft.Json.dll via NuGet package:
# - install nuget package in directory "build"
# - copy Newtonsoft.Json.dll into directory "build"
RUN nuget install Newtonsoft.Json -Version 12.0.3 -OutputDirectory /build
RUN cd Newtonsoft.Json.12.0.3/lib/net40 && cp Newtonsoft.Json.dll /build
# Copy source file into the filesystem of the container
ADD PingPong.cs .
# Build solution
RUN mcs /reference:M2Mqtt.Net.dll /reference:Newtonsoft.Json.dll PingPong.cs
# ------ STAGE 2 (application container) -----------------
FROM mono:6.8.0-slim
# create working directory
ADD . /pingpong
WORKDIR /pingpong
# install nuget
RUN apt update && apt install -y nuget
# Install mqtt client in container
RUN nuget install M2Mqtt
#copy just the compiled application and libraries from the previous stage into this stage
COPY --from=build-env /build .
# Run exe
CMD [ "mono", "./PingPong.exe"]