2021-07-13 18:29:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Use BuildKit, otherwise building on ARM fails
|
|
|
|
export DOCKER_BUILDKIT=1
|
|
|
|
|
2023-03-14 19:27:14 +00:00
|
|
|
IMAGE_NAME=freqtradeorg/freqtrade
|
2023-03-15 18:06:08 +00:00
|
|
|
CACHE_IMAGE=freqtradeorg/freqtrade_cache
|
2023-03-14 19:27:14 +00:00
|
|
|
GHCR_IMAGE_NAME=ghcr.io/freqtrade/freqtrade
|
2023-03-15 18:06:08 +00:00
|
|
|
|
2021-07-13 18:29:49 +00:00
|
|
|
# Replace / with _ to create a valid tag
|
|
|
|
TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g")
|
|
|
|
TAG_PLOT=${TAG}_plot
|
2022-08-16 07:26:02 +00:00
|
|
|
TAG_FREQAI=${TAG}_freqai
|
2022-11-24 06:00:12 +00:00
|
|
|
TAG_FREQAI_RL=${TAG_FREQAI}rl
|
2021-07-13 18:29:49 +00:00
|
|
|
TAG_PI="${TAG}_pi"
|
|
|
|
|
|
|
|
TAG_ARM=${TAG}_arm
|
|
|
|
TAG_PLOT_ARM=${TAG_PLOT}_arm
|
2022-08-16 07:26:02 +00:00
|
|
|
TAG_FREQAI_ARM=${TAG_FREQAI}_arm
|
2022-11-24 06:00:12 +00:00
|
|
|
TAG_FREQAI_RL_ARM=${TAG_FREQAI_RL}_arm
|
2021-07-13 18:29:49 +00:00
|
|
|
|
|
|
|
echo "Running for ${TAG}"
|
|
|
|
|
|
|
|
# Add commit and commit_message to docker container
|
|
|
|
echo "${GITHUB_SHA}" > freqtrade_commit
|
|
|
|
|
|
|
|
if [ "${GITHUB_EVENT_NAME}" = "schedule" ]; then
|
|
|
|
echo "event ${GITHUB_EVENT_NAME}: full rebuild - skipping cache"
|
|
|
|
# Build regular image
|
|
|
|
docker build -t freqtrade:${TAG_ARM} .
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "event ${GITHUB_EVENT_NAME}: building with cache"
|
|
|
|
# Build regular image
|
|
|
|
docker pull ${IMAGE_NAME}:${TAG_ARM}
|
|
|
|
docker build --cache-from ${IMAGE_NAME}:${TAG_ARM} -t freqtrade:${TAG_ARM} .
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed building multiarch images"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2021-07-30 19:23:09 +00:00
|
|
|
docker build --cache-from freqtrade:${TAG_ARM} --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_ARM} -t freqtrade:${TAG_PLOT_ARM} -f docker/Dockerfile.plot .
|
2022-08-16 07:26:02 +00:00
|
|
|
docker build --cache-from freqtrade:${TAG_ARM} --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_ARM} -t freqtrade:${TAG_FREQAI_ARM} -f docker/Dockerfile.freqai .
|
2022-11-24 06:00:12 +00:00
|
|
|
docker build --cache-from freqtrade:${TAG_ARM} --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_ARM} -t freqtrade:${TAG_FREQAI_RL_ARM} -f docker/Dockerfile.freqai_rl .
|
2021-07-13 18:29:49 +00:00
|
|
|
|
2023-03-15 18:06:08 +00:00
|
|
|
# Tag image for upload and next build step
|
|
|
|
docker tag freqtrade:$TAG_ARM ${CACHE_IMAGE}:$TAG_ARM
|
2021-07-13 18:29:49 +00:00
|
|
|
docker tag freqtrade:$TAG_PLOT_ARM ${CACHE_IMAGE}:$TAG_PLOT_ARM
|
2022-08-16 07:26:02 +00:00
|
|
|
docker tag freqtrade:$TAG_FREQAI_ARM ${CACHE_IMAGE}:$TAG_FREQAI_ARM
|
2022-11-24 06:00:12 +00:00
|
|
|
docker tag freqtrade:$TAG_FREQAI_RL_ARM ${CACHE_IMAGE}:$TAG_FREQAI_RL_ARM
|
2021-07-13 18:29:49 +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_ARM} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3
|
2021-07-13 18:29:49 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed running backtest"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
docker images
|
|
|
|
|
|
|
|
docker push ${CACHE_IMAGE}:$TAG_PLOT_ARM
|
2022-08-16 07:26:02 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_FREQAI_ARM
|
2022-11-24 06:00:12 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL_ARM
|
2021-07-13 18:29:49 +00:00
|
|
|
docker push ${CACHE_IMAGE}:$TAG_ARM
|
|
|
|
|
2021-07-16 18:11:27 +00:00
|
|
|
# Create multi-arch image
|
2021-07-13 18:29:49 +00:00
|
|
|
# Make sure that all images contained here are pushed to github first.
|
|
|
|
# Otherwise installation might fail.
|
|
|
|
echo "create manifests"
|
|
|
|
|
2023-01-25 13:34:52 +00:00
|
|
|
docker manifest create ${IMAGE_NAME}:${TAG} ${CACHE_IMAGE}:${TAG} ${CACHE_IMAGE}:${TAG_ARM} ${IMAGE_NAME}:${TAG_PI}
|
2021-07-13 18:29:49 +00:00
|
|
|
docker manifest push -p ${IMAGE_NAME}:${TAG}
|
|
|
|
|
2023-01-25 13:34:52 +00:00
|
|
|
docker manifest create ${IMAGE_NAME}:${TAG_PLOT} ${CACHE_IMAGE}:${TAG_PLOT} ${CACHE_IMAGE}:${TAG_PLOT_ARM}
|
2021-07-13 18:29:49 +00:00
|
|
|
docker manifest push -p ${IMAGE_NAME}:${TAG_PLOT}
|
|
|
|
|
2023-01-25 13:34:52 +00:00
|
|
|
docker manifest create ${IMAGE_NAME}:${TAG_FREQAI} ${CACHE_IMAGE}:${TAG_FREQAI} ${CACHE_IMAGE}:${TAG_FREQAI_ARM}
|
2022-08-16 07:26:02 +00:00
|
|
|
docker manifest push -p ${IMAGE_NAME}:${TAG_FREQAI}
|
|
|
|
|
2023-01-25 13:34:52 +00:00
|
|
|
docker manifest create ${IMAGE_NAME}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL_ARM}
|
2022-11-24 06:00:12 +00:00
|
|
|
docker manifest push -p ${IMAGE_NAME}:${TAG_FREQAI_RL}
|
|
|
|
|
2023-03-15 18:06:08 +00:00
|
|
|
# copy images to ghcr.io
|
2023-03-15 05:46:31 +00:00
|
|
|
|
2023-03-16 18:33:56 +00:00
|
|
|
alias crane="docker run --rm -i -v $(pwd)/.crane:/home/nonroot/.docker/ gcr.io/go-containerregistry/crane"
|
2023-03-15 19:41:08 +00:00
|
|
|
mkdir .crane
|
|
|
|
chmod a+rwx .crane
|
2023-03-15 05:46:31 +00:00
|
|
|
|
2023-03-15 19:41:08 +00:00
|
|
|
echo "${GHCR_TOKEN}" | crane auth login ghcr.io -u "${GHCR_USERNAME}" --password-stdin
|
2023-03-15 05:46:31 +00:00
|
|
|
|
2023-03-15 18:06:08 +00:00
|
|
|
crane copy ${IMAGE_NAME}:${TAG} ${GHCR_IMAGE_NAME}:${TAG}
|
|
|
|
crane copy ${IMAGE_NAME}:${TAG_PLOT} ${GHCR_IMAGE_NAME}:${TAG_PLOT}
|
|
|
|
crane copy ${IMAGE_NAME}:${TAG_FREQAI} ${GHCR_IMAGE_NAME}:${TAG_FREQAI}
|
|
|
|
crane copy ${IMAGE_NAME}:${TAG_FREQAI_RL} ${GHCR_IMAGE_NAME}:${TAG_FREQAI_RL}
|
2023-03-14 19:27:14 +00:00
|
|
|
|
2021-07-30 19:23:09 +00:00
|
|
|
# Tag as latest for develop builds
|
2021-07-13 18:29:49 +00:00
|
|
|
if [ "${TAG}" = "develop" ]; then
|
2023-01-25 11:20:10 +00:00
|
|
|
echo 'Tagging image as latest'
|
2021-07-30 19:23:09 +00:00
|
|
|
docker manifest create ${IMAGE_NAME}:latest ${CACHE_IMAGE}:${TAG_ARM} ${IMAGE_NAME}:${TAG_PI} ${CACHE_IMAGE}:${TAG}
|
|
|
|
docker manifest push -p ${IMAGE_NAME}:latest
|
2023-03-15 05:46:31 +00:00
|
|
|
|
2023-03-15 18:06:08 +00:00
|
|
|
crane copy ${IMAGE_NAME}:latest ${GHCR_IMAGE_NAME}:latest
|
2021-07-13 18:29:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
docker images
|
2023-03-15 19:41:08 +00:00
|
|
|
rm -rf .crane
|
2021-07-13 18:29:49 +00:00
|
|
|
|
2021-08-14 06:46:19 +00:00
|
|
|
# Cleanup old images from arm64 node.
|
|
|
|
docker image prune -a --force --filter "until=24h"
|