1
1
ARG UBUNTU_VERSION=22.04
2
2
ARG TARGETARCH=amd64
3
- ARG CARDANO_NODE_VERSION=1.35.5
3
+ ARG CARDANO_NODE_VERSION=1.35.7
4
4
ARG CARDANO_DB_SYNC_VERSION=13.1.0.0
5
5
ARG NODEJS_MAJOR_VERSION=14
6
6
@@ -19,53 +19,53 @@ RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/
19
19
--extra-conf "trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \
20
20
--init none --no-confirm
21
21
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
22
- RUN mkdir -p /app
23
- WORKDIR /app
24
- # Note: since we don’t officially support `aarch64-linux`, we have to tweak the source a bit
25
- # in this case; but otherwise, build straight from GitHub:
26
- RUN \
27
- if [ "$TARGETARCH" = "arm64" ]; then \
28
- mkdir -p src && cd src &&\
29
- git clone https://github.com/input-output-hk/cardano-node.git &&\
30
- cd cardano-node &&\
31
- git fetch --all --tags &&\
32
- git checkout ${CARDANO_NODE_VERSION} &&\
33
- echo '["aarch64-linux"]' >nix/supported-systems.nix &&\
34
- cd ../.. &&\
35
- nix build -L -o cardano-node ./src/cardano-node#legacyPackages.aarch64-linux.hydraJobs.musl.cardano-node ;\
36
- else \
37
- nix build -L -o cardano-node github:input-output-hk/cardano-node/${CARDANO_NODE_VERSION}#legacyPackages.x86_64-linux.hydraJobs.musl.cardano-node ;\
38
- fi
39
- RUN \
40
- if [ "$TARGETARCH" = "arm64" ]; then \
41
- nix build -L -o cardano-cli ./src/cardano-node#legacyPackages.aarch64-linux.hydraJobs.musl.cardano-cli ;\
42
- else \
43
- nix build -L -o cardano-cli github:input-output-hk/cardano-node/${CARDANO_NODE_VERSION}#legacyPackages.x86_64-linux.hydraJobs.musl.cardano-cli ;\
44
- fi
45
- RUN \
46
- mkdir -p src && cd src &&\
47
- git clone https://github.com/input-output-hk/cardano-db-sync.git &&\
48
- cd cardano-db-sync &&\
49
- git fetch --all --tags &&\
50
- git checkout ${CARDANO_DB_SYNC_VERSION} &&\
51
- cd ../.. &&\
52
- if [ "$TARGETARCH" = "arm64" ]; then \
53
- echo '["aarch64-linux"]' >src/cardano-db-sync/supported-systems.nix &&\
54
- nix build -L -o cardano-db-sync--tar ./src/cardano-db-sync#hydraJobs.cardano-db-sync-linux.aarch64-linux ;\
55
- else \
56
- nix build -L -o cardano-db-sync--tar ./src/cardano-db-sync#hydraJobs.cardano-db-sync-linux.x86_64-linux ;\
57
- fi &&\
58
- mkdir cardano-db-sync && cd cardano-db-sync &&\
59
- tar -xf ../cardano-db-sync--tar/cardano-db-sync*.tar.gz && chown -R 0:0 . && chmod -R -w . && cd ..
22
+ # We don’t officially support AArch64, so we have to go through some hops:
23
+ SHELL ["/bin/bash" , "-c" ]
24
+ RUN mkdir -p /app && cat >/app/default.nix <<<$'\n \
25
+ let\n \
26
+ system = "' "$([ " $TARGETPLATFORM" = " linux/arm64" ] && echo " aarch64-linux" || echo " x86_64-linux")" $'";\n \
27
+ _nodeFlake = __getFlake "github:input-output-hk/cardano-node/' "${CARDANO_NODE_VERSION}" $'";\n \
28
+ _dbSyncFlake = __getFlake "github:input-output-hk/cardano-db-sync/' "${CARDANO_DB_SYNC_VERSION}" $'";\n \
29
+ pkgs = _nodeFlake.inputs.nixpkgs.legacyPackages.${system};\n \
30
+ nix-bundle-exe = import (fetchTarball "https://github.com/3noch/nix-bundle-exe/archive/3522ae68aa4188f4366ed96b41a5881d6a88af97.zip") { inherit pkgs; };\n \
31
+ enableAArch64 = original: supportedSystemsPath:\n \
32
+ if system == "x86_64-linux" then original\n \
33
+ else if system == "aarch64-linux" then let\n \
34
+ patched = pkgs.runCommandNoCC "patched" {} "cp -r ${original} $out && chmod -R +w $out && echo ${with pkgs; with lib; escapeShellArg (__toJSON [system])} >$out/${supportedSystemsPath}";\n \
35
+ in (import _nodeFlake.inputs.flake-compat {\n \
36
+ src = {\n \
37
+ inherit (patched) outPath;\n \
38
+ inherit (original) rev shortRev lastModified lastModifiedDate;\n \
39
+ };\n \
40
+ }).defaultNix else throw "unsupported system: ${system}";\n \
41
+ nodeFlake = enableAArch64 _nodeFlake "nix/supported-systems.nix";\n \
42
+ dbSyncFlake = enableAArch64 _dbSyncFlake "supported-systems.nix";\n \
43
+ in\n \
44
+ # cardano-node doesn’t build for ARM before 1.35.7:\n \
45
+ assert system != "aarch64-linux" || _nodeFlake.sourceInfo.lastModifiedDate >= "20230328184650";\n \
46
+ {\n \
47
+ inherit _nodeFlake;\n \
48
+ cardano-node = nix-bundle-exe nodeFlake.packages.${system}.cardano-node;\n \
49
+ cardano-cli = nix-bundle-exe nodeFlake.packages.${system}.cardano-cli;\n \
50
+ cardano-db-sync = nix-bundle-exe dbSyncFlake.packages.${system}.cardano-db-sync;\n \
51
+ schema = pkgs.runCommandNoCC "schema" {} "cp -r ${_dbSyncFlake}/schema $out";\n \
52
+ }\n \
53
+ ' && cat /app/default.nix
54
+ SHELL ["/bin/sh" , "-c" ]
55
+ # Note: ‘GC_DONT_GC=1’ prevents rare segfaults in Nix’s Boehm GC:
56
+ RUN GC_DONT_GC=1 nix-build /app/default.nix -A cardano-node -o /app/cardano-node
57
+ RUN GC_DONT_GC=1 nix-build /app/default.nix -A cardano-cli -o /app/cardano-cli
58
+ RUN GC_DONT_GC=1 nix-build /app/default.nix -A cardano-db-sync -o /app/cardano-db-sync
59
+ RUN GC_DONT_GC=1 nix-build /app/default.nix -A schema -o /app/schema
60
+ RUN mkdir -p /opt && cp -rL /app/cardano-node /app/cardano-cli /app/cardano-db-sync /app/schema /opt/
60
61
61
- # Note: one more stage to detect Haskell errors earlier :
62
+ # One more stage to detect Haskell errors early :
62
63
FROM ${TARGETARCH}/ubuntu:${UBUNTU_VERSION} as haskell-runtime
63
- COPY --from=haskell-builder /app/cardano-node/bin/cardano-node /usr/local/bin/
64
- COPY --from=haskell-builder /app/cardano-cli/bin/cardano-cli /usr/local/bin/
65
- COPY --from=haskell-builder /app/cardano-db-sync/cardano-db-sync /usr/local/bin/
66
- COPY --from=haskell-builder /app/src/cardano-db-sync/schema /cardano-db-sync/schema
67
- RUN cardano-node --version && cardano-cli --version && cardano-db-sync --version
68
- RUN ls -alh /cardano-db-sync/schema
64
+ COPY --from=haskell-builder /opt/ /opt/
65
+ RUN stat /opt/schema &&\
66
+ /opt/cardano-node/bin/cardano-node --version &&\
67
+ /opt/cardano-cli/bin/cardano-cli --version &&\
68
+ /opt/cardano-db-sync/bin/cardano-db-sync --version
69
69
70
70
FROM ${TARGETARCH}/ubuntu:${UBUNTU_VERSION} as ubuntu-nodejs
71
71
ARG NODEJS_MAJOR_VERSION
@@ -93,8 +93,10 @@ RUN curl --proto '=https' --tlsv1.2 -sSf -L https://www.postgresql.org/media/key
93
93
postgresql-12 \
94
94
postgresql-client-12 &&\
95
95
npm install pm2 -g
96
- COPY --from=haskell-runtime /usr/local/bin/* /usr/local/bin/
97
- COPY --from=haskell-runtime /cardano-db-sync/schema /cardano-db-sync/schema
96
+ COPY --from=haskell-builder /opt/ /opt/
97
+ RUN ln -s /opt/cardano-node/bin/* /opt/cardano-cli/bin/* /opt/cardano-db-sync/bin/* /usr/local/bin/ &&\
98
+ mkdir -p /cardano-db-sync &&\
99
+ ln -s /opt/schema /cardano-db-sync/schema
98
100
# Configure dynamic linker
99
101
RUN ldconfig
100
102
# easy step-down from root
@@ -144,9 +146,8 @@ RUN yarn --offline --frozen-lockfile --non-interactive --production
144
146
145
147
FROM ubuntu-nodejs as cardano-rosetta-server
146
148
ARG NETWORK=mainnet
147
- COPY --from=haskell-runtime /usr/local/bin/cardano-cli \
148
- /usr/local/bin/cardano-node \
149
- /usr/local/bin/
149
+ COPY --from=haskell-builder /opt/ /opt/
150
+ RUN ln -s /opt/cardano-node/bin/* /opt/cardano-cli/bin/* /usr/local/bin/
150
151
COPY --from=rosetta-server-builder /app/dist /cardano-rosetta-server/dist
151
152
COPY --from=rosetta-server-production-deps /app/node_modules /cardano-rosetta-server/node_modules
152
153
COPY config/network/${NETWORK} /config/
0 commit comments