Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
* Rename crypto-exporter.sh to crypto-exporter
Browse files Browse the repository at this point in the history
* Drop the `find` in build.sh
* Split the Dockerfile into multi-staged build
* Change the user from `root` to `crypto-exporter`
* Prepare release v1.7.9
  • Loading branch information
tlex committed Oct 25, 2020
1 parent b25547b commit 68987af
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 33 deletions.
63 changes: 42 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
FROM alpine:latest as builder
COPY exporter/requirements.txt /work/exporter/requirements.txt
RUN set -xeu; \
mkdir -p /work/wheels; \
apk add \
python3-dev \
openssl-dev \
gcc \
musl-dev \
libffi-dev \
make \
; \
python3 -m ensurepip; \
pip3 install -U \
pip \
wheel \
;
RUN pip3 --use-feature=2020-resolver wheel -r /work/exporter/requirements.txt -w /work/wheels
COPY exporter /work/exporter/

FROM alpine:latest
LABEL maintainer="[email protected]" \
ai.ix.repository="ix.ai/crypto-exporter"
LABEL maintainer="[email protected]"
LABEL ai.ix.repository="ix.ai/crypto-exporter"

COPY --from=builder /work /

COPY exporter/requirements.txt /exporter/requirements.txt
RUN set -xeu; \
ls -lashi /wheels; \
apk add --no-cache python3; \
python3 -m ensurepip; \
pip3 install --no-cache-dir -U pip;\
pip3 install \
--no-index \
--use-feature=2020-resolver \
--no-cache-dir \
--find-links /wheels \
--requirement /exporter/requirements.txt \
; \
rm -rf /wheels; \
addgroup crypto-exporter; \
adduser -G crypto-exporter -D -H crypto-exporter

RUN apk --no-cache upgrade && \
apk add --no-cache py3-prometheus-client \
py3-requests \
py3-cryptography \
py3-multidict \
py3-aiohttp \
py3-pip \
py3-toml \
py3-numpy \
py3-pynacl \
py3-urllib3 \
py3-yarl && \
apk add --no-cache python3-dev gcc musl-dev libffi-dev make && \
pip3 install --no-cache-dir -r exporter/requirements.txt && \
apk del --purge --no-cache gcc musl-dev python3-dev py3-pip libffi-dev
COPY crypto-exporter /usr/local/bin/crypto-exporter

COPY exporter/ /exporter
COPY crypto-exporter.sh /usr/local/bin/crypto-exporter.sh
USER crypto-exporter:crypto-exporter

EXPOSE 9188

ENTRYPOINT ["/usr/local/bin/crypto-exporter.sh"]
ENTRYPOINT ["/usr/local/bin/crypto-exporter"]
9 changes: 5 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env sh

echo "Setting VERSION"
find . -name .git -type d -prune -o -type f -name constants.py -exec sed -i s/^VERSION.*/VERSION\ =\ \'${CI_COMMIT_REF_NAME:-None}\'/g {} + -exec grep VERSION {} +
echo "Setting BUILD"
find . -name .git -type d -prune -o -type f -name constants.py -exec sed -i s/^BUILD.*/BUILD\ =\ \'${CI_PIPELINE_ID:-None}\'/g {} + -exec grep BUILD {} +
set -xeu

if [ -n "${CI_PIPELINE_ID:-}" ]; then
sed -i "s|^BUILD.*|BUILD = '${CI_PIPELINE_ID}'|g" exporter/lib/constants.py
fi
File renamed without changes.
6 changes: 3 additions & 3 deletions exporter/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

WARN_TICKER_SLOW_LOAD = 'Exchange doesn\'t support fetching all the tickers in one go. Loading them individually.'

# These get set at build time
VERSION = None
BUILD = None
VERSION = 'v1.7.9'
# Gets set automatically at build time
BUILD = 'dev'
2 changes: 1 addition & 1 deletion exporter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ccxt==1.36.80
prometheus_client==0.8.0
requests==2.24.0
pygelf==0.3.6
stellar-sdk==2.8.1
ccxt==1.36.80
8 changes: 4 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ set -e
./build.sh

for EXCHANGE in "kraken" "binance" "coinbasepro"; do
EXCHANGE="${EXCHANGE}" REFERENCE_CURRENCY="EUR" SYMBOLS="BTC/EUR" TEST=y ./crypto-exporter.sh
EXCHANGE="${EXCHANGE}" REFERENCE_CURRENCY="EUR" SYMBOLS="BTC/EUR" TEST=y ./crypto-exporter
done

# ETH
if [ -n "${ETHERSCAN_API_KEY}" ]; then
ADDRESSES='0x742d35Cc6634C0532925a3b844Bc454e4438f44e' # binance
ADDRESSES="${ADDRESSES},0x53d284357ec70cE289D6D64134DfAc8E511c8a3D" # kraken
TOKENS='[{"contract":"0x9b70740e708a083c6ff38df52297020f5dfaa5ee","name":"Daneel","short":"DAN","decimals": 10},{"contract":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","name":"USD Coin","short":"USDC","decimals": 6}]'
EXCHANGE="etherscan" ADDRESSES="${ADDRESSES}" TOKENS="${TOKENS}" API_KEY="${ETHERSCAN_API_KEY}" TEST=y ./crypto-exporter.sh
EXCHANGE="etherscan" ADDRESSES="${ADDRESSES}" TOKENS="${TOKENS}" API_KEY="${ETHERSCAN_API_KEY}" TEST=y ./crypto-exporter
fi

# Ripple
ADDRESSES='rDbWJ9C7uExThZYAwV8m6LsZ5YSX3sa6US' # ripple.com
ADDRESSES="${ADDRESSES},rEy8TFcrAPvhpKrwyrscNYyqBGUkE9hKaJ" # binance
ADDRESSES="${ADDRESSES},rLHzPsX6oXkzU2qL12kHCH8G8cnZv1rBJh" # kraken
EXCHANGE="ripple" ADDRESSES="${ADDRESSES}" TEST=y ./crypto-exporter.sh
EXCHANGE="ripple" ADDRESSES="${ADDRESSES}" TEST=y ./crypto-exporter

# Stellar
ADDRESSES='GA5XIGA5C7QTPTWXQHY6MCJRMTRZDOSHR6EFIBNDQTCQHG262N4GGKTM' # kraken
ADDRESSES="${ADDRESSES},GD6RMKTCHQGEOGYWIKSY5G7QWXPZOAEZIKPKEVZUAXOQCZRVBRRFGLJM" # NydroEnergy
ADDRESSES="${ADDRESSES},GCNSGHUCG5VMGLT5RIYYZSO7VQULQKAJ62QA33DBC5PPBSO57LFWVV6P" # InterstellarExchange
EXCHANGE="stellar" ADDRESSES="${ADDRESSES}" TEST=y ./crypto-exporter.sh
EXCHANGE="stellar" ADDRESSES="${ADDRESSES}" TEST=y ./crypto-exporter

0 comments on commit 68987af

Please sign in to comment.