2018-10-03 20:12:23 +02:00
## This base image is for running latest chainquery
2018-10-16 09:28:03 +02:00
FROM ubuntu:18.04 as prep
LABEL MAINTAINER="leopere [at] nixc [dot] us"
2018-10-02 23:22:47 +02:00
2018-11-06 22:23:12 +01:00
## Install everything needed to unzip the file containing Chainquery
2018-10-16 09:28:03 +02:00
RUN apt-get update && \
2018-11-05 04:42:35 +01:00
apt-get -y install unzip curl && \
2018-10-03 20:12:23 +02:00
apt-get autoclean -y && \
2018-11-05 04:42:35 +01:00
rm -rf /var/lib/apt/lists/* && \
mkdir /download
2018-10-03 20:12:23 +02:00
2018-11-06 22:23:12 +01:00
## Download and extract the latest Zip containing Linux binary for Chainquery.
2018-11-05 04:42:35 +01:00
RUN curl -L -o /download/chainquery.zip $(curl -s https://api.github.com/repos/lbryio/chainquery/releases | fgrep 'Linux_x86_64.zip' | grep download | head -n 1 | cut -d'"' -f4) && \
cd /download && \
ls -lAh /download && pwd && \
unzip chainquery.zip && \
rm chainquery.zip
2018-11-06 22:23:12 +01:00
## TODO: Use this instead of everything above here at some point. To do this we will need the LBRY team to host all of their release binaries in their latest form internally I guess since github doesn't support latest tags.
2018-11-05 04:42:35 +01:00
# ADD --chown=1000:1000 https://github.com/lbryio/chainquery/releases/download/latest/chainquery_latest_Linux_x86_64.zip /download
2018-10-16 09:28:03 +02:00
2018-11-06 22:23:12 +01:00
# TODO: Switch to Alpine eventually we might need to compile in Alpine for this.
2018-10-16 09:28:03 +02:00
FROM ubuntu:18.04 as app
2018-11-06 22:23:12 +01:00
## Run as unprivileged user.
2018-10-16 09:28:03 +02:00
RUN adduser chainquery --gecos GECOS --shell /bin/bash --disabled-password --home /home/chainquery
2018-11-06 22:23:12 +01:00
# Pull chainquery executable from prep container.
2018-11-05 04:42:35 +01:00
COPY --from=0 /download/chainquery /usr/bin
# ADD --chown=1000:1000 https://github.com/lbryio/chainquery/releases/download/latest/chainquery_latest_Linux_x86_64.zip /usr/bin
COPY chainqueryconfig.toml /etc/chainquery/
2018-11-06 22:23:12 +01:00
## Get latest chainqueryconfig.toml from master on github as template.
# TODO: add magic which pattern matches for chainqueryconfig.toml DEFAULT strings and replaces them with configured settings on container start.
2018-11-05 04:42:35 +01:00
ADD --chown=1000:1000 https://raw.githubusercontent.com/lbryio/chainquery/master/config/default/chainqueryconfig.toml /etc/chainquery/chainqueryconfig.toml.orig
2018-11-06 22:23:12 +01:00
## Install start.sh as executable script in container $PATH
2018-10-16 09:28:03 +02:00
COPY start.sh /usr/local/bin/start
2018-10-03 20:12:23 +02:00
2018-11-06 22:23:12 +01:00
# TODO: Implement docker-entrypoint if later required this might be handy if we need certain maintainence tasks to be executed in the live container.
# COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
## From here onward we're doing this with no root.
2018-10-03 20:30:18 +02:00
USER chainquery
2018-10-03 20:12:23 +02:00
## Expose Chainquery API port
2018-10-16 09:28:03 +02:00
EXPOSE 6300
2018-10-03 20:12:23 +02:00
2018-11-06 22:23:12 +01:00
## Execute start script earlier installed into $PATH
2018-10-03 20:12:23 +02:00
CMD ["start"]