-
Notifications
You must be signed in to change notification settings - Fork 10
/
Dockerfile
94 lines (66 loc) · 3.03 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
# APSIM Next Generation
#
# A container for running APSIM Next Generation.
#
# To build this container, run this from the ApsimX directory (after building apsim):
# docker build -t apsiminitiative/apsimng .
# To run the container:
# docker run -i --rm -v "$PWD:/apsim" apsiminitiative/apsimng path/to/my/file.apsimx
# Build apsim in an intermediate container
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build
# Builder of this image may specify an commit (commit hash) and version number of the build.
# These are optional, but if set, the specified commit will be built, and stamped with the
# version number.
ARG commit
ARG version
RUN git clone https://github.com/APSIMInitiative/ApsimX /apsim
WORKDIR /apsim
# If commit variable is set, attempt to checkout the specified commit.
RUN echo commit=$commit && git checkout $commit
# If version variable is set, version stamp the build.
RUN echo version=$version && sed -i -e "s/0\.0\.0\.0/$version/g" \
/apsim/Models/Properties/AssemblyVersion.cs
# Build apsim.
RUN dotnet publish --nologo -c Release -f net6.0 -r linux-x64 --no-self-contained /apsim/Models/Models.csproj
# The actual image is based on dotnet/runtime.
# docker build <build args> --target apsimng -t apsiminitiative/apsimng:latest .
FROM mcr.microsoft.com/dotnet/runtime:6.0-bullseye-slim as apsimng
# Install sqlite3
RUN apt update -q --silent && \
apt install -yq libsqlite3-dev
# Copy build artifacts from the intermediate container to /apsim
COPY --from=build /apsim/bin/Release/net6.0/linux-x64/publish /opt/apsim/
# Add apsim to path
ENV PATH $PATH:/opt/apsim
# Set shell to bash (best shell :)
SHELL ["bash", "-c"]
# Entrypoint is Models CLI
ENTRYPOINT ["Models"]
# Repeat the same steps using apsim-r as the base image, in order to build
# apsimng-complete.
# docker build <build args> --target apsimng-complete -t apsiminitiative/apsimng-complete:latest .
FROM apsiminitiative/apsimng-r:latest as apsimng-complete
# Install sqlite3
RUN apt update -q --silent && \
apt install -yq libsqlite3-dev
# Copy build artifacts from the intermediate container to /apsim
COPY --from=build /apsim/bin/Release/net6.0/linux-x64/publish /opt/apsim/
# Add apsim to path
ENV PATH $PATH:/opt/apsim
# Set shell to bash (best shell :)
SHELL ["bash", "-c"]
# Entrypoint is Models CLI
ENTRYPOINT ["Models"]
# Build the GUI in another intermediate image
FROM build as build-apsimng-gui
RUN dotnet publish -c Release -f net6.0 -r linux-x64 --no-self-contained /apsim/ApsimNG/ApsimNG.csproj
# GUI image uses apsimng as base image
# docker build <build args> --target apsimng-gui -t apsiminitiative/apsimng-gui:latest .
FROM apsimng as apsimng-gui
# Copy build artifacts from the intermediate container to /opt/apsim
COPY --from=build-apsimng-gui /apsim/bin/Release/net6.0/linux-x64/publish/ /opt/apsim/
# Install graphical libraries.
RUN apt update -q --silent && \
apt install -yq gtk-sharp3 \
libgtksourceview-4-0
ENTRYPOINT ["ApsimNG"]