Skip to content

Commit 7cf7b36

Browse files
committed
RA-60: WIP: Github action added
1 parent 5a55a79 commit 7cf7b36

File tree

3 files changed

+283
-21
lines changed

3 files changed

+283
-21
lines changed

.github/workflows/docker-build.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: GitHub Actions Demo
2+
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
3+
on: [push]
4+
jobs:
5+
Explore-GitHub-Actions:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
9+
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
10+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
11+
- name: Check out repository code
12+
uses: actions/checkout@v4
13+
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
14+
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
15+
- name: List files in the repository
16+
run: |
17+
ls ${{ github.workspace }}
18+
- run: echo "🍏 This job's status is ${{ job.status }}."

docker/Dockerfile

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM ubuntu:24.04
22

3+
WORKDIR /root
4+
35
# Install dependencies
46
RUN apt-get update -qq --fix-missing
57

@@ -20,16 +22,17 @@ RUN bash -c "ghcup upgrade"
2022

2123
# Install cabal
2224
ENV CABAL_VERSION=3.8.1.0
23-
RUN bash -c "ghcup install cabal $CABAL_VERSION"
24-
RUN bash -c "ghcup set cabal $CABAL_VERSION."
25+
RUN bash -c "ghcup install cabal ${CABAL_VERSION}"
26+
RUN bash -c "ghcup set cabal ${CABAL_VERSION}"
2527

2628
# Install GHC
2729
ENV GHC_VERSION=8.10.7
28-
RUN bash -c "ghcup install ghc $GHC_VERSION"
29-
RUN bash -c "ghcup set ghc $GHC_VERSION"
30+
RUN bash -c "ghcup install ghc ${GHC_VERSION}"
31+
RUN bash -c "ghcup set ghc ${GHC_VERSION}"
32+
33+
WORKDIR /root/src
3034

31-
ARG CARDANO_NODE_VERSION=8.7.3
32-
RUN mkdir -p ~/src && cd ~/src
35+
ENV CARDANO_NODE_VERSION=8.7.3
3336

3437
#Install sodium
3538
RUN export IOHKNIX_VERSION=$(curl https://raw.githubusercontent.com/IntersectMBO/cardano-node/$CARDANO_NODE_VERSION/flake.lock | jq -r '.nodes.iohkNix.locked.rev') \
@@ -85,9 +88,11 @@ RUN export BLST_VERSION=$(curl https://raw.githubusercontent.com/input-output-hk
8588
&& cp libblst.pc /usr/local/lib/pkgconfig/ \
8689
&& cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/ \
8790
&& cp libblst.a /usr/local/lib \
88-
# && chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}} \
91+
&& bash -c "chmod u=rw,go=r /usr/local/{lib/{libblst.a,pkgconfig/libblst.pc},include/{blst.{h,hpp},blst_aux.h}}" \
8992
&& cd ..
9093

94+
RUN apt -y --no-install-recommends install libsecp256k1-dev
95+
9196
#Install node
9297
ENV NODE_VERSION=8.9.2
9398

@@ -109,29 +114,33 @@ RUN git clone https://github.com/intersectmbo/cardano-node.git \
109114
&& echo "" >> cabal.project.local \
110115
&& mkdir -p /usr/local/opt/openssl \
111116
&& ln -s /opt/homebrew/opt/openssl@3/lib /usr/local/opt/openssl/lib \
112-
&& ln -s /opt/homebrew/opt/openssl@3/include /usr/local/opt/openssl/include \
113-
&& cd ..
117+
&& ln -s /opt/homebrew/opt/openssl@3/include /usr/local/opt/openssl/include
118+
119+
WORKDIR /root/src/cardano-node
114120

115121
RUN bash -c "cabal update"
116122
RUN bash -c "cabal build all"
117123
RUN bash -c "cabal build cardano-cli"
118124

119-
RUN kdir -p ~/.local/bin \
125+
RUN mkdir -p ~/.local/bin \
120126
&& cp -p "$(./scripts/bin-path.sh cardano-node)" ~/.local/bin/ \
121-
&& cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/
127+
&& cp -p "$(./scripts/bin-path.sh cardano-cli)" ~/.local/bin/ \
128+
&& cd ..
122129

123130
RUN cardano-cli --version
124131

125-
ARG CARDANO_NODE_SOCKET="./node-ipc"
126-
ARG CARDANO_NODE_DB="./node/db"
127-
#ARG CARDANO_CONFIG="./docker/${NETWORK}"
128-
ARG CARDANO_CONFIG="./docker/config/${NETWORK}"
129-
130-
COPY ${CARDANO_NODE_SOCKET} /node/ipc
131-
COPY ${CARDANO_NODE_DB} /node/data/db
132-
COPY ${CARDANO_CONFIG} /node/config
133-
134-
EXPOSE 3001 12788 12798
132+
WORKDIR /root
133+
134+
#ARG CARDANO_NODE_SOCKET="./node-ipc"
135+
#ARG CARDANO_NODE_DB="./node/db"
136+
##ARG CARDANO_CONFIG="./docker/${NETWORK}"
137+
#ARG CARDANO_CONFIG="./docker/config/${NETWORK}"
138+
#
139+
#COPY ${CARDANO_NODE_SOCKET} /node/ipc
140+
#COPY ${CARDANO_NODE_DB} /node/data/db
141+
#COPY ${CARDANO_CONFIG} /node/config
142+
#
143+
#EXPOSE 3001 12788 12798
135144

136145
#ENTRYPOINT cardano-node run --database-path /data/db --host-addr 0.0.0.0 --port 3001 --socket-path /node/ipc/node.socket --topology /node/config/topology.json --config /node/config/config.json
137146
CMD ["/bin/sh", "-c", "bash"]

docker/Dockerfile_example

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
ARG UBUNTU_VERSION=22.04
2+
FROM ubuntu:${UBUNTU_VERSION} AS cardano-builder
3+
# Following: https://github.com/input-output-hk/cardano-node-wiki/blob/main/docs/getting-started/install.md
4+
ENV DEBIAN_FRONTEND=nonintercative
5+
ARG CABAL_VERSION=3.10.1.0
6+
ARG GHC_VERSION=8.10.7
7+
ARG IOHK_LIBSODIUM_GIT_REV=dbb48cce
8+
ARG SECP256K1_VERSION=v0.3.2
9+
ARG BLST_VERSION=v0.3.11
10+
11+
ARG NODE_VERSION=8.7.3
12+
ARG CARDANO_DB_SYNC_VERSION=13.2.0.1
13+
14+
RUN mkdir -p /app/src
15+
WORKDIR /app
16+
RUN apt-get update -y && apt-get install -y \
17+
automake \
18+
autoconf \
19+
build-essential \
20+
g++ \
21+
git \
22+
jq \
23+
libffi-dev \
24+
libghc-postgresql-libpq-dev \
25+
libgmp-dev \
26+
liblmdb-dev \
27+
libnuma-dev \
28+
libncursesw5 \
29+
libpq-dev \
30+
libssl-dev \
31+
libsystemd-dev \
32+
libtinfo-dev \
33+
llvm-dev \
34+
libtool \
35+
make \
36+
pkg-config \
37+
tmux \
38+
wget \
39+
zlib1g-dev
40+
41+
WORKDIR /app/src
42+
# Cabal
43+
ENV CABAL_VERSION=${CABAL_VERSION}
44+
ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:/root/.local/bin:$PATH"
45+
RUN wget https://downloads.haskell.org/~cabal/cabal-install-${CABAL_VERSION}/cabal-install-${CABAL_VERSION}-$(uname -m)-linux-ubuntu20_04.tar.xz \
46+
&& tar -xf cabal-install-${CABAL_VERSION}-$(uname -m)-linux-ubuntu20_04.tar.xz \
47+
&& rm cabal-install-${CABAL_VERSION}-$(uname -m)-linux-ubuntu20_04.tar.xz \
48+
&& mkdir -p ~/.local/bin \
49+
&& mv cabal ~/.local/bin/ \
50+
&& cabal update && cabal --version
51+
52+
# GHC
53+
ENV GHC_VERSION=${GHC_VERSION}
54+
RUN wget https://downloads.haskell.org/~ghc/${GHC_VERSION}/ghc-${GHC_VERSION}-$(uname -m)-deb10-linux.tar.xz \
55+
&& tar -xf ghc-${GHC_VERSION}-$(uname -m)-deb10-linux.tar.xz \
56+
&& rm ghc-${GHC_VERSION}-$(uname -m)-deb10-linux.tar.xz \
57+
&& cd ghc-${GHC_VERSION} \
58+
&& ./configure \
59+
&& make install
60+
61+
62+
# Libsodium
63+
RUN git clone https://github.com/intersectmbo/libsodium && \
64+
cd libsodium && \
65+
git checkout ${LIBSODIUM_REF} && \
66+
./autogen.sh && \
67+
./configure && \
68+
make && \
69+
make install
70+
ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
71+
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
72+
73+
# secp256k1
74+
RUN git clone https://github.com/bitcoin-core/secp256k1 && \
75+
cd secp256k1 && \
76+
git checkout ${SECP256K1_REF} && \
77+
./autogen.sh && \
78+
./configure --enable-module-schnorrsig --enable-experimental && \
79+
make && \
80+
make install
81+
82+
# BLST
83+
COPY ./scripts/libblst.pc /usr/local/lib/pkgconfig/
84+
RUN git clone https://github.com/supranational/blst && \
85+
cd blst && \
86+
git checkout ${BLST_REF} && \
87+
./build.sh && \
88+
cp bindings/blst_aux.h bindings/blst.h bindings/blst.hpp /usr/local/include/ && \
89+
cp libblst.a /usr/local/lib/ && \
90+
chmod u=rw,go=r /usr/local/lib/pkgconfig/libblst.pc \
91+
/usr/local/include/blst_aux.h /usr/local/include/blst.h /usr/local/include/blst.hpp \
92+
/usr/local/lib/libblst.a
93+
94+
# Install cardano-node
95+
ENV NODE_VERSION=${NODE_VERSION}
96+
RUN echo "Building tags/${NODE_VERSION}..." \
97+
&& echo tags/${NODE_VERSION} > /CARDANO_BRANCH \
98+
&& git clone https://github.com/intersectmbo/cardano-node.git \
99+
&& cd cardano-node \
100+
&& git fetch --all --recurse-submodules --tags \
101+
&& git tag \
102+
&& git checkout tags/${NODE_VERSION} \
103+
&& echo "with-compiler: ghc-${GHC_VERSION}" >> cabal.project.local \
104+
&& echo "tests: False" >> cabal.project.local \
105+
&& cabal update \
106+
&& cabal build all \
107+
&& cabal build cardano-cli
108+
RUN cd cardano-node \
109+
&& mkdir -p /root/.local/bin/ \
110+
&& cp -p "$(./scripts/bin-path.sh cardano-node)" /root/.local/bin/ \
111+
&& cp -p "$(./scripts/bin-path.sh cardano-cli)" /root/.local/bin/
112+
113+
RUN export PATH="/root/.local/bin:$PATH"
114+
115+
ARG DB_SYNC_TAG=${CARDANO_DB_SYNC_VERSION}
116+
WORKDIR /app/src
117+
RUN git clone https://github.com/intersectmbo/cardano-db-sync.git &&\
118+
cd cardano-db-sync &&\
119+
git fetch --all --tags &&\
120+
git checkout tags/${DB_SYNC_TAG}
121+
RUN apt-get update -y && apt-get install -y libpq-dev
122+
RUN cd cardano-db-sync &&\
123+
echo "with-compiler: ghc-8.10.7" >> cabal.project.local &&\
124+
cabal update && \
125+
cabal configure --with-compiler=ghc-${GHC_VERSION} &&\
126+
cabal build cardano-db-sync
127+
RUN cp -p "$(find . -name cardano-db-sync -executable -type f)" /root/.local/bin/
128+
129+
FROM ubuntu:${UBUNTU_VERSION} as ubuntu-nodejs
130+
ARG NODEJS_MAJOR_VERSION=18
131+
ENV DEBIAN_FRONTEND=nonintercative
132+
RUN apt-get update && apt-get install curl -y &&\
133+
curl --proto '=https' --tlsv1.2 -sSf -L https://deb.nodesource.com/setup_${NODEJS_MAJOR_VERSION}.x | bash - &&\
134+
apt-get install nodejs -y
135+
136+
FROM ubuntu-nodejs as nodejs-builder
137+
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - &&\
138+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list &&\
139+
apt-get update && apt-get install gcc g++ make gnupg2 yarn -y
140+
141+
FROM ubuntu-nodejs as runtime-base
142+
ARG TARGETARCH
143+
RUN \
144+
apt-get update -y && apt-get install lsb-release -y; \
145+
if [ "$TARGETARCH" = "arm64" ]; then \
146+
apt-get install -y libnuma-dev=2.0.*; \
147+
fi
148+
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - &&\
149+
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list &&\
150+
apt-get update && apt-get install -y --no-install-recommends \
151+
ca-certificates \
152+
jq \
153+
postgresql-12 \
154+
postgresql-client-12 &&\
155+
npm install pm2 -g
156+
COPY --from=cardano-builder /usr/local/lib /usr/local/lib
157+
COPY --from=cardano-builder /usr/local/include/ /usr/local/include/
158+
COPY --from=cardano-builder /root/.local/bin/cardano-* /usr/local/bin/
159+
COPY --from=cardano-builder /app/src/cardano-db-sync/schema /cardano-db-sync/schema
160+
# Configure dynamic linker
161+
RUN ldconfig
162+
# easy step-down from root
163+
# https://github.com/tianon/gosu/releases
164+
ENV GOSU_VERSION 1.12
165+
RUN set -eux; \
166+
savedAptMark="$(apt-mark showmanual)"; \
167+
rm -rf /var/lib/apt/lists/*; \
168+
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
169+
curl --proto '=https' --tlsv1.2 -sSf -L -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}"; \
170+
curl --proto '=https' --tlsv1.2 -sSf -L -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}.asc"; \
171+
export GNUPGHOME="$(mktemp -d)"; \
172+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
173+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
174+
gpgconf --kill all; \
175+
rm -rf "${GNUPGHOME}" /usr/local/bin/gosu.asc; \
176+
apt-mark auto '.*' > /dev/null; \
177+
[ -z "${savedAptMark}" ] || apt-mark manual ${savedAptMark} > /dev/null; \
178+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
179+
chmod +x /usr/local/bin/gosu; \
180+
gosu --version; \
181+
gosu nobody true
182+
RUN mkdir /ipc
183+
VOLUME /data
184+
EXPOSE 8080
185+
ENTRYPOINT ["./entrypoint.sh"]
186+
187+
FROM nodejs-builder as rosetta-server-base
188+
RUN mkdir -p /app/src
189+
WORKDIR /app
190+
COPY cardano-rosetta-server/packages-cache /app/packages-cache
191+
COPY cardano-rosetta-server/package.json \
192+
cardano-rosetta-server/yarn.lock \
193+
cardano-rosetta-server/.yarnrc \
194+
/app/
195+
196+
FROM rosetta-server-base as rosetta-server-builder
197+
COPY cardano-rosetta-server/tsconfig-dist.json \
198+
cardano-rosetta-server/tsconfig.json \
199+
/app/
200+
RUN yarn --offline --frozen-lockfile --non-interactive
201+
COPY cardano-rosetta-server/src /app/src
202+
RUN yarn build
203+
204+
FROM rosetta-server-base as rosetta-server-production-deps
205+
RUN yarn --offline --frozen-lockfile --non-interactive --production
206+
207+
FROM ubuntu-nodejs as cardano-rosetta-server
208+
ARG NETWORK=mainnet
209+
COPY --from=cardano-builder /root/.local/bin/cardano-cli \
210+
/root/.local/bin/cardano-node \
211+
/usr/local/bin/
212+
COPY --from=rosetta-server-builder /app/dist /cardano-rosetta-server/dist
213+
COPY --from=rosetta-server-production-deps /app/node_modules /cardano-rosetta-server/node_modules
214+
COPY config/network/${NETWORK} /config/
215+
EXPOSE 8080
216+
CMD ["node", "/cardano-rosetta-server/dist/src/server/index.js"]
217+
218+
FROM runtime-base
219+
COPY --from=cardano-builder /root/.local/bin/cardano-cli /usr/local/bin/
220+
ARG NETWORK=mainnet
221+
ARG SNAPSHOT_URL
222+
ENV DEFAULT_RELATIVE_TTL=1000 LOGGER_MIN_SEVERITY=info PAGE_SIZE=25 DEFAULT_POOL_DEPOSIT=500000000 DEFAULT_KEY_DEPOSIT=2000000
223+
ENV CARDANO_CLI_PATH=/usr/local/bin/cardano-cli
224+
COPY --from=rosetta-server-builder /app/dist /cardano-rosetta-server/dist
225+
COPY --from=rosetta-server-production-deps /app/node_modules /cardano-rosetta-server/node_modules
226+
COPY ecosystem.config.js .
227+
COPY postgresql.conf /etc/postgresql/12/main/postgresql.conf
228+
COPY scripts/start_cardano-db-sync.sh scripts/maybe_download_cardano-db-sync_snapshot.sh /scripts/
229+
COPY config/network/${NETWORK} /config/
230+
ENV PGPASSFILE=/config/cardano-db-sync/pgpass
231+
RUN echo "/var/run/postgresql:5432:cexplorer:*:*" > $PGPASSFILE &&\
232+
chmod 600 $PGPASSFILE && chown postgres:postgres $PGPASSFILE
233+
RUN mkdir /snapshot &&\
234+
./scripts/maybe_download_cardano-db-sync_snapshot.sh $SNAPSHOT_URL /snapshot
235+
COPY scripts/entrypoint.sh .

0 commit comments

Comments
 (0)