/
Dockerfile.sharp.sources.from_binaries
122 lines (103 loc) · 5.75 KB
/
Dockerfile.sharp.sources.from_binaries
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS Build
# Install system dependencies.
RUN set -x \
&& apt-get update \
&& apt-get install -y \
unzip \
wget
# Publish neo-cli from source as a self-contained deployment into /neo-cli folder (all dependant .dlls are included).
# See https://docs.microsoft.com/ru-ru/dotnet/core/deploying/#publish-self-contained for details.
ENV CLIBRANCH="v3.6.0"
RUN wget -O /tmp/neo-cli.zip https://github.com/neo-project/neo-node/archive/${CLIBRANCH}.zip && \
unzip -q -d /tmp/neo-node/ /tmp/neo-cli.zip && \
mkdir /build && \
cp -r /tmp/neo-node/*/neo-cli /build && \
cp -r tmp/neo-node/*/Neo.ConsoleService /build && \
cp tmp/neo-node/*/NuGet.Config /build/neo-cli && \
dotnet restore /build/neo-cli && \
dotnet publish -c Release --framework net7.0 /build/neo-cli -o /neo-cli && \
rm -rf /build /tmp/neo-cli.zip /tmp/neo-node
# Build neo-modules from source into /Plugins folder (only plugin .dll and plugin config are included, if you need other dependant .dlls, see the next step)
ENV MODULESBRANCH="v3.6.1"
ENV MODULES="DBFTPlugin LevelDBStore RocksDBStore RpcServer"
RUN wget -O /tmp/neo-modules.zip https://github.com/neo-project/neo-modules/archive/${MODULESBRANCH}.zip && \
unzip -q -d /tmp/neo-modules/ /tmp/neo-modules.zip && \
mkdir /Plugins && \
for mod in ${MODULES}; do \
dotnet restore /tmp/neo-modules/*/src/${mod}/; \
dotnet build -c Release /tmp/neo-modules/*/src/${mod}/; \
mkdir /Plugins/${mod}; \
cp -r /tmp/neo-modules/*/src/${mod}/bin/Release/net7.0/* /Plugins/${mod}; \
done
# Sometimes Plugins need extra .dlls which can not be retrieved from build folder.
# Use `dotnet publish` instead of `dotnet build` and copy all necessary .dlls from `publish` folder.
# For example, RpsServer Plugin needs Microsoft.AspNetCore.ResponseCompression.dll:
RUN dotnet publish -c Release --framework net7.0 /tmp/neo-modules/*/src/RpcServer/ && \
# cp /tmp/neo-modules/*/src/RpcServer/bin/Release/net7.0/publish/Microsoft.AspNetCore.ResponseCompression.dll /Plugins/ && \
dotnet publish -c Release --framework net7.0 /tmp/neo-modules/*/src/RocksDBStore/ && \
cp /tmp/neo-modules/*/src/RocksDBStore/bin/Release/net7.0/publish/RocksDbSharp.dll /Plugins/ && \
rm -rf /tmp/neo-modules.zip /tmp/neo-modules
# Publish neo-vm from source as a self-contained deployment into /neo-vm folder (although neo-vm does not have dependant .dlls)
ENV NEOVMBRANCH="v3.6.0"
RUN wget -O /tmp/neo-vm.zip https://github.com/neo-project/neo-vm/archive/${NEOVMBRANCH}.zip && \
unzip -q -d /tmp/neo-vm/ /tmp/neo-vm.zip && \
ls -l /tmp/* && \
dotnet restore /tmp/neo-vm/*/src/Neo.VM/ && \
dotnet publish -c Release --framework net7.0 /tmp/neo-vm/*/src/Neo.VM/ -o /neo-vm && \
rm -rf /tmp/neo-vm.zip tmp/neo-vm
# Publish neo from source as a self-contained deployment into /neo folder (all dependant .dlls are included)
ENV NEOBRANCH="v3.6.0"
RUN wget -O /tmp/neo.zip https://github.com/neo-project/neo/archive/${NEOBRANCH}.zip && \
unzip -q -d /tmp/neo/ /tmp/neo.zip && \
dotnet restore /tmp/neo/*/src/Neo/ && \
dotnet publish -c Release --framework net7.0 /tmp/neo/*/src/Neo/ -o /neo && \
rm -rf /tmp/neo.zip tmp/neo
# All things are published, so build the final image by copying binaries from Build
FROM mcr.microsoft.com/dotnet/aspnet:7.0 as Final
# Frontend non-interactive
ENV DEBIAN_FRONTEND noninteractive
# Disable dotnet usage information collection
# https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#behavior
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
# Install system dependencies. always should be done in one line
# https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#run
RUN set -x \
&& apt-get update \
&& apt-get install -y \
libleveldb-dev \
curl \
jq \
libssl-dev \
libunwind8 \
librocksdb-dev \
libc6-dev \
iproute2 \
# APT cleanup to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Copy neo-cli and all dependant .dlls from Build
COPY --from=Build /neo-cli /neo-cli/
# Copy Plugins without dependant .dlls from Build
COPY --from=Build /Plugins /neo-cli/Plugins/
# Replace existing neo.dll (it's one of the neo-cli dependencies) with the built one from /neo/ folder of Build.
# Comment this step in case if you need neo.dll from neo-cli.
# IMPORTANT: if there's a mismatch between neo-cli's and neo's version, be careful with their dependencies.
# All neo dependent .dlls have version of neo-cli (as far as we copied the whole pack of neo-cli dependencies).
# If you need any particular .dll to have version of neo (not neo-cli), just copy this neo dependent .dll from /neo/ into /neo-cli/ folder, e.g.:
# COPY --from-Build /neo/NeoDependentLibrary.dll /neo-cli/
COPY --from=Build /neo/Neo.Json.dll /neo-cli/
COPY --from=Build /neo/Neo.dll /neo-cli/
COPY --from=Build /neo/BouncyCastle.Crypto.dll /neo-cli/
# Replace existing Neo.VM.dll (it's one of the neo-cli dependencies) with the built one from /neo-vm/ folder of Build.
# Comment this step in case if you need Neo.VM.dll from neo-cli.
COPY --from=Build /neo-vm/Neo.VM.dll /neo-cli/
# A welcome message for bash users
RUN echo "printf \"\n* Please report issues to https://github.com/CityOfZion/neo-local\n\n\"" >> /root/.bashrc
WORKDIR /neo-cli
RUN chmod +x /neo-cli/neo-cli
COPY ./sharp.entrypoint.sh /entrypoint.sh
COPY ./sharp.healthcheck.sh /healthcheck.sh
COPY ./sharp.rpc.config.json /neo-cli/Plugins/RpcServer/config.json
COPY ./sharp.dbft.config.json /neo-cli/Plugins/DBFTPlugin/config.json
#COPY ./sharp.statesdumper.config.json /neo-cli/Plugins/StatesDumper/config.json
#COPY ./sharp.applicationlogs.config.json /neo-cli/Plugins/ApplicationLogs/config.json
ENTRYPOINT [ "/entrypoint.sh" ]