forked from hashgraph/hedera-mirror-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
61 lines (52 loc) · 2.71 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
# This Dockerfile configuration is used to build
# Importer, Rosetta and PostgreSQL into one image
# and run the services using supervisord
FROM ubuntu:20.04 as builder
ARG DEBIAN_FRONTEND=noninteractive
# GIT_REF can be a branch or a tag
ARG GIT_REF=main
RUN apt-get update && apt-get install -y gcc git openjdk-11-jdk-headless
RUN git clone -b ${GIT_REF} --depth 1 https://github.com/hashgraph/hedera-mirror-node
WORKDIR /hedera-mirror-node
RUN ./mvnw clean package -DskipTests -pl hedera-mirror-importer,hedera-mirror-rosetta
WORKDIR /app
RUN mkdir importer rosetta scripts \
&& cp /hedera-mirror-node/hedera-mirror-rosetta/build/* . \
&& cp /hedera-mirror-node/hedera-mirror-importer/target/hedera-mirror-importer-*exec.jar ./importer/hedera-mirror-importer.jar \
&& cp /hedera-mirror-node/hedera-mirror-rosetta/bin/hedera-mirror-rosetta ./rosetta \
&& cp /hedera-mirror-node/hedera-mirror-importer/src/main/resources/db/scripts/init.sh ./scripts
# ######################################################################## #
# --------------------------- Runner Container --------------------------- #
# ######################################################################## #
FROM ubuntu:20.04 as runner
# ---------------------- Install Deps & PosgreSQL ------------------------ #
# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
ARG DEBIAN_FRONTEND=noninteractive
ENV PG_VERSION=13
RUN apt-get update \
&& apt-get install -y ca-certificates curl gnupg lsb-release \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 \
&& echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y postgresql-${PG_VERSION} postgresql-client-${PG_VERSION} supervisor openjdk-11-jre-headless \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app /app
# Create users for importer and rosetta
RUN useradd -s /bin/bash importer && useradd -s /bin/bash rosetta
ENV PATH="/usr/lib/postgresql/${PG_VERSION}/bin:${PATH}"
ENV PGCONF="/var/lib/postgresql/${PG_VERSION}/main"
ENV PGDATA=${PGCONF}
USER postgres
RUN cp -r /etc/postgresql/${PG_VERSION}/main/* ${PGCONF} \
&& rm -fr /etc/postgresql/${PG_VERSION}/main \
&& ln -s ${PGCONF} /etc/postgresql/${PG_VERSION}/main \
&& cp /app/pg_hba.conf ${PGCONF}/ \
&& cp /app/postgresql.conf ${PGCONF}/conf.d
# Init db script
RUN /etc/init.d/postgresql start && /app/scripts/init.sh && /etc/init.d/postgresql stop
USER root
WORKDIR /app
# Expose the ports (DB)(Rosetta)
EXPOSE 5432 5700
ENTRYPOINT [ "./run_supervisord.sh" ]