2018-08-13 17:59:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-05-30 17:15:59 +00:00
|
|
|
# The below assumes a correctly setup docker buildx environment
|
|
|
|
|
2023-03-15 18:06:08 +00:00
|
|
|
IMAGE_NAME=freqtradeorg/freqtrade
|
|
|
|
CACHE_IMAGE=freqtradeorg/freqtrade_cache
|
2019-11-05 14:33:48 +00:00
|
|
|
# Replace / with _ to create a valid tag
|
2019-11-11 09:36:38 +00:00
|
|
|
TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g")
|
2020-09-20 12:58:27 +00:00
|
|
|
TAG_PLOT=${TAG}_plot
|
2022-08-16 14:39:29 +00:00
|
|
|
TAG_FREQAI=${TAG}_freqai
|
2022-11-24 06:00:12 +00:00
|
|
|
TAG_FREQAI_RL=${TAG_FREQAI}rl
|
2023-04-08 10:09:53 +00:00
|
|
|
TAG_FREQAI_RL=${TAG_FREQAI}torch
|
2021-05-30 17:15:59 +00:00
|
|
|
TAG_PI="${TAG}_pi"
|
|
|
|
|
|
|
|
PI_PLATFORM="linux/arm/v7"
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "Running for ${TAG}"
|
2021-07-16 18:11:27 +00:00
|
|
|
CACHE_TAG=${CACHE_IMAGE}:${TAG_PI}_cache
|
2018-08-13 17:59:56 +00:00
|
|
|
|
2018-12-02 21:49:30 +00:00
|
|
|
# Add commit and commit_message to docker container
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "${GITHUB_SHA}" > freqtrade_commit
|
2018-12-02 21:49:30 +00:00
|
|
|
|
2019-11-11 18:42:05 +00:00
|
|
|
if [ "${GITHUB_EVENT_NAME}" = "schedule" ]; then
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "event ${GITHUB_EVENT_NAME}: full rebuild - skipping cache"
|
2021-05-30 17:15:59 +00:00
|
|
|
# Build regular image
|
2018-10-21 12:00:01 +00:00
|
|
|
docker build -t freqtrade:${TAG} .
|
2021-05-30 17:15:59 +00:00
|
|
|
# Build PI image
|
|
|
|
docker buildx build \
|
|
|
|
--cache-to=type=registry,ref=${CACHE_TAG} \
|
|
|
|
-f docker/Dockerfile.armhf \
|
|
|
|
--platform ${PI_PLATFORM} \
|
2023-01-25 13:34:52 +00:00
|
|
|
-t ${IMAGE_NAME}:${TAG_PI} \
|
|
|
|
--push \
|
|
|
|
--provenance=false \
|
|
|
|
.
|
2018-10-21 12:00:01 +00:00
|
|
|
else
|
2019-11-05 14:33:48 +00:00
|
|
|
echo "event ${GITHUB_EVENT_NAME}: building with cache"
|
2021-05-30 17:15:59 +00:00
|
|
|
# Build regular image
|
2019-01-08 19:09:32 +00:00
|
|
|
docker pull ${IMAGE_NAME}:${TAG}
|
2018-10-21 12:00:01 +00:00
|
|
|
docker build --cache-from ${IMAGE_NAME}:${TAG} -t freqtrade:${TAG} .
|
2021-05-30 17:15:59 +00:00
|
|
|
|
|
|
|
# Pull last build to avoid rebuilding the whole image
|
|
|
|
# docker pull --platform ${PI_PLATFORM} ${IMAGE_NAME}:${TAG}
|
2023-01-25 13:34:52 +00:00
|
|
|
# disable provenance due to https://github.com/docker/buildx/issues/1509
|
2021-05-30 17:15:59 +00:00
|
|
|
docker buildx build \
|
|
|
|
--cache-from=type=registry,ref=${CACHE_TAG} \
|
|
|
|
--cache-to=type=registry,ref=${CACHE_TAG} \
|
|
|
|
-f docker/Dockerfile.armhf \
|
|
|
|
--platform ${PI_PLATFORM} \
|
2023-01-25 13:34:52 +00:00
|
|
|
-t ${IMAGE_NAME}:${TAG_PI} \
|
|
|
|
--push \
|
|
|
|
--provenance=false \
|
|
|
|
.
|
2021-05-30 17:15:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed building multiarch images"
|
|
|
|
return 1
|
2018-10-21 12:00:01 +00:00
|
|
|
fi
|
2020-09-28 06:36:40 +00:00
|
|
|
# Tag image for upload and next build step
|
2021-07-13 18:29:49 +00:00
|
|
|
docker tag freqtrade:$TAG ${CACHE_IMAGE}:$TAG
|
2020-09-28 06:36:40 +00:00
|
|
|
|
2023-03-31 04:49:12 +00:00
|
|
|
docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG} -t freqtrade:${TAG_PLOT} -f docker/Dockerfile.plot .
|
|
|
|
docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG} -t freqtrade:${TAG_FREQAI} -f docker/Dockerfile.freqai .
|
|
|
|
docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG_FREQAI} -t freqtrade:${TAG_FREQAI_RL} -f docker/Dockerfile.freqai_rl .
|
2018-10-21 12:00:01 +00:00
|
|
|
|
2021-07-13 18:29:49 +00:00
|
|
|
docker tag freqtrade:$TAG_PLOT ${CACHE_IMAGE}:$TAG_PLOT
|
2022-08-16 07:26:02 +00:00
|
|
|
docker tag freqtrade:$TAG_FREQAI ${CACHE_IMAGE}:$TAG_FREQAI
|
2022-11-24 06:00:12 +00:00
|
|
|
docker tag freqtrade:$TAG_FREQAI_RL ${CACHE_IMAGE}:$TAG_FREQAI_RL
|
2023-04-08 10:09:53 +00:00
|
|
|
docker tag freqtrade:$TAG_FREQAI_RL ${CACHE_IMAGE}:$TAG_FREQAI_TORCH
|
2020-09-28 06:36:40 +00:00
|
|
|
|
2018-08-13 17:59:56 +00:00
|
|
|
# Run backtest
|
2021-09-21 18:18:14 +00:00
|
|
|
docker run --rm -v $(pwd)/config_examples/config_bittrex.example.json:/freqtrade/config.json:ro -v $(pwd)/tests:/tests freqtrade:${TAG} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3
|
2018-08-13 17:59:56 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed running backtest"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2021-05-30 17:15:59 +00:00
|
|
|
docker images
|
|
|
|
|
2023-01-25 13:34:52 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG
|
2021-07-13 18:29:49 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_PLOT
|
2022-08-16 07:26:02 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_FREQAI
|
2022-11-24 06:00:12 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL
|
2018-08-13 17:59:56 +00:00
|
|
|
|
2021-05-30 17:15:59 +00:00
|
|
|
docker images
|
2021-05-27 08:23:08 +00:00
|
|
|
|
2018-08-13 17:59:56 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2021-05-30 17:15:59 +00:00
|
|
|
echo "failed building image"
|
2018-08-13 17:59:56 +00:00
|
|
|
return 1
|
|
|
|
fi
|