diff --git a/.github/actions/docker-tags/action.yml b/.github/actions/docker-tags/action.yml new file mode 100644 index 000000000..1a563aade --- /dev/null +++ b/.github/actions/docker-tags/action.yml @@ -0,0 +1,92 @@ +name: 'docker-tags' +description: 'Set Docker default Tag environment variables' +# inputs: +outputs: + BRANCH_NAME: + description: 'The branch name' + value: ${{ steps.tags.outputs.BRANCH_NAME }} + TAG: + description: 'The Docker tag' + value: ${{ steps.tags.outputs.TAG }} + TAG_PLOT: + description: 'The Docker tag for the plot' + value: ${{ steps.tags.outputs.TAG_PLOT }} + TAG_FREQAI: + description: 'The Docker tag for the freqai' + value: ${{ steps.tags.outputs.TAG_FREQAI }} + TAG_FREQAI_RL: + description: 'The Docker tag for the freqai_rl' + value: ${{ steps.tags.outputs.TAG_FREQAI_RL }} + TAG_FREQAI_TORCH: + description: 'The Docker tag for the freqai_torch' + value: ${{ steps.tags.outputs.TAG_FREQAI_TORCH }} + TAG_ARM: + description: 'The Docker tag for the arm' + value: ${{ steps.tags.outputs.TAG_ARM }} + TAG_PLOT_ARM: + description: 'The Docker tag for the plot arm' + value: ${{ steps.tags.outputs.TAG_PLOT_ARM }} + TAG_FREQAI_ARM: + description: 'The Docker tag for the freqai arm' + value: ${{ steps.tags.outputs.TAG_FREQAI_ARM }} + TAG_FREQAI_RL_ARM: + description: 'The Docker tag for the freqai_rl arm' + value: ${{ steps.tags.outputs.TAG_FREQAI_RL_ARM }} + TAG_PI: + description: 'The Docker tag for the pi' + value: ${{ steps.tags.outputs.TAG_PI }} + CACHE_TAG_PI: + description: 'The Docker cache tag for the pi' + value: ${{ steps.tags.outputs.CACHE_TAG_PI }} +runs: + using: "composite" + steps: + - name: Extract branch name + shell: bash + id: tags + env: + BRANCH_NAME_INPUT: ${{ github.event.inputs.branch_name }} + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + BRANCH_NAME="${BRANCH_NAME_INPUT}" + else + BRANCH_NAME="${GITHUB_REF##*/}" + fi + + # Replace / with _ to create a valid tag + TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g") + TAG_PLOT=${TAG}_plot + TAG_FREQAI=${TAG}_freqai + TAG_FREQAI_RL=${TAG_FREQAI}rl + TAG_FREQAI_TORCH=${TAG_FREQAI}torch + + TAG_ARM=${TAG}_arm + TAG_PLOT_ARM=${TAG_PLOT}_arm + TAG_FREQAI_ARM=${TAG_FREQAI}_arm + TAG_FREQAI_RL_ARM=${TAG_FREQAI_RL}_arm + + TAG_PI="${TAG}_pi" + + CACHE_TAG_PI=${CACHE_IMAGE}:${TAG_PI}_cache + + echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_OUTPUT" + echo "TAG=${TAG}" >> "$GITHUB_OUTPUT" + echo "TAG_PLOT=${TAG_PLOT}" >> "$GITHUB_OUTPUT" + echo "TAG_FREQAI=${TAG_FREQAI}" >> "$GITHUB_OUTPUT" + echo "TAG_FREQAI_RL=${TAG_FREQAI_RL}" >> "$GITHUB_OUTPUT" + echo "TAG_FREQAI_TORCH=${TAG_FREQAI_TORCH}" >> "$GITHUB_OUTPUT" + echo "TAG_ARM=${TAG_ARM}" >> "$GITHUB_OUTPUT" + echo "TAG_PLOT_ARM=${TAG_PLOT_ARM}" >> "$GITHUB_OUTPUT" + echo "TAG_FREQAI_ARM=${TAG_FREQAI_ARM}" >> "$GITHUB_OUTPUT" + echo "TAG_FREQAI_RL_ARM=${TAG_FREQAI_RL_ARM}" >> "$GITHUB_OUTPUT" + echo "TAG_PI=${TAG_PI}" >> "$GITHUB_OUTPUT" + + echo "CACHE_TAG_PI=${CACHE_TAG_PI}" >> "$GITHUB_OUTPUT" + + cat "$GITHUB_OUTPUT" + + - name: Save commit SHA to file + shell: bash + # Add commit to docker container + run: | + echo "${GITHUB_SHA}" > freqtrade_commit diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index a781dbd17..1fc50315b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -24,6 +24,7 @@ env: IMAGE_NAME: "freqtradeorg/freqtrade" CACHE_IMAGE: "freqtradeorg/freqtrade_cache" GHCR_IMAGE_NAME: "ghcr.io/freqtrade/freqtrade" + PI_PLATFORM: "linux/arm/v7" jobs: deploy-docker: @@ -36,23 +37,9 @@ jobs: with: persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Extract branch name - env: - BRANCH_NAME_INPUT: ${{ github.event.inputs.branch_name }} - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - BRANCH_NAME="${BRANCH_NAME_INPUT}" - else - BRANCH_NAME="${GITHUB_REF##*/}" - fi - echo "GITHUB_REF='${GITHUB_REF}'" - echo "BRANCH_NAME='${BRANCH_NAME}'" - echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_ENV" + - name: Set docker tag names + id: tags + uses: ./.github/actions/docker-tags - name: Login to Docker Hub uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 @@ -60,9 +47,10 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Set up QEMU uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 + with: + cache-image: false - name: Set up Docker Buildx id: buildx @@ -73,9 +61,86 @@ jobs: env: PLATFORMS: ${{ steps.buildx.outputs.platforms }} - - name: Build and test and push docker images + - name: Build image without cache + if: github.event_name == 'schedule' + env: + TAG: ${{ steps.tags.outputs.TAG }} run: | - build_helpers/publish_docker_multi.sh + docker build -t ${CACHE_IMAGE}:${TAG} . + + - name: Build ARMHF image without cache + if: github.event_name == 'schedule' + env: + TAG_PI: ${{ steps.tags.outputs.TAG_PI }} + CACHE_TAG_PI: ${{ steps.tags.outputs.CACHE_TAG_PI }} + run: | + docker buildx build \ + --cache-to=type=registry,ref=${CACHE_TAG_PI} \ + -f docker/Dockerfile.armhf \ + --platform ${PI_PLATFORM} \ + -t ${IMAGE_NAME}:${TAG_PI} \ + --push \ + --provenance=false \ + . + + - name: Build image with cache + if: github.event_name != 'schedule' + env: + TAG: ${{ steps.tags.outputs.TAG }} + run: | + docker pull ${IMAGE_NAME}:${TAG} || true + docker build --cache-from ${IMAGE_NAME}:${TAG} -t ${CACHE_IMAGE}:${TAG} . + + - name: Build ARMHF image with cache + if: github.event_name != 'schedule' + # disable provenance due to https://github.com/docker/buildx/issues/1509 + env: + TAG_PI: ${{ steps.tags.outputs.TAG_PI }} + CACHE_TAG_PI: ${{ steps.tags.outputs.CACHE_TAG_PI }} + run: | + docker buildx build \ + --cache-from=type=registry,ref=${CACHE_TAG_PI} \ + --cache-to=type=registry,ref=${CACHE_TAG_PI} \ + -f docker/Dockerfile.armhf \ + --platform ${PI_PLATFORM} \ + -t ${IMAGE_NAME}:${TAG_PI} \ + --push \ + --provenance=false \ + . + + - name: Run build for AI images + env: + TAG: ${{ steps.tags.outputs.TAG }} + TAG_PLOT: ${{ steps.tags.outputs.TAG_PLOT }} + TAG_FREQAI: ${{ steps.tags.outputs.TAG_FREQAI }} + TAG_FREQAI_RL: ${{ steps.tags.outputs.TAG_FREQAI_RL }} + run: | + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG} -t ${CACHE_IMAGE}:${TAG_PLOT} -f docker/Dockerfile.plot . + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG} -t ${CACHE_IMAGE}:${TAG_FREQAI} -f docker/Dockerfile.freqai . + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_FREQAI} -t ${CACHE_IMAGE}:${TAG_FREQAI_RL} -f docker/Dockerfile.freqai_rl . + + + - name: Run backtest in Docker + env: + TAG: ${{ steps.tags.outputs.TAG }} + run: | + docker run --rm -v $(pwd)/tests/testdata/config.tests.json:/freqtrade/config.json:ro -v $(pwd)/tests:/tests ${CACHE_IMAGE}:${TAG} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3 + + - name: Push cache images + env: + TAG: ${{ steps.tags.outputs.TAG }} + TAG_PLOT: ${{ steps.tags.outputs.TAG_PLOT }} + TAG_FREQAI: ${{ steps.tags.outputs.TAG_FREQAI }} + TAG_FREQAI_RL: ${{ steps.tags.outputs.TAG_FREQAI_RL }} + run: | + docker push ${CACHE_IMAGE}:$TAG + docker push ${CACHE_IMAGE}:$TAG_PLOT + docker push ${CACHE_IMAGE}:$TAG_FREQAI + docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL + + - name: list Images + run: | + docker images deploy-arm: name: "Deploy Docker ARM64" @@ -91,18 +156,9 @@ jobs: with: persist-credentials: false - - name: Extract branch name - env: - BRANCH_NAME_INPUT: ${{ github.event.inputs.branch_name }} - run: | - if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - BRANCH_NAME="${BRANCH_NAME_INPUT}" - else - BRANCH_NAME="${GITHUB_REF##*/}" - fi - echo "GITHUB_REF='${GITHUB_REF}'" - echo "BRANCH_NAME='${BRANCH_NAME}'" - echo "BRANCH_NAME=${BRANCH_NAME}" >> "$GITHUB_ENV" + - name: Set docker tag names + id: tags + uses: ./.github/actions/docker-tags - name: Login to Docker Hub uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 @@ -110,12 +166,125 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and test and push docker images + - name: Login to github + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build image without cache + if: github.event_name == 'schedule' env: - GHCR_USERNAME: ${{ github.actor }} - GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} run: | - build_helpers/publish_docker_arm64.sh + docker build -t ${IMAGE_NAME}:${TAG_ARM} . + + - name: Build image with cache + if: github.event_name != 'schedule' + env: + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} + run: | + docker pull ${IMAGE_NAME}:${TAG_ARM} || true + docker build --cache-from ${IMAGE_NAME}:${TAG_ARM} -t ${CACHE_IMAGE}:${TAG_ARM} . + + - name: Run build for AI images + env: + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} + TAG_PLOT_ARM: ${{ steps.tags.outputs.TAG_PLOT_ARM }} + TAG_FREQAI_ARM: ${{ steps.tags.outputs.TAG_FREQAI_ARM }} + TAG_FREQAI_RL_ARM: ${{ steps.tags.outputs.TAG_FREQAI_RL_ARM }} + run: | + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_ARM} -t ${CACHE_IMAGE}:${TAG_PLOT_ARM} -f docker/Dockerfile.plot . + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_ARM} -t ${CACHE_IMAGE}:${TAG_FREQAI_ARM} -f docker/Dockerfile.freqai . + docker build --build-arg sourceimage=${CACHE_IMAGE} --build-arg sourcetag=${TAG_FREQAI_ARM} -t ${CACHE_IMAGE}:${TAG_FREQAI_RL_ARM} -f docker/Dockerfile.freqai_rl . + + + - name: Run backtest in Docker + env: + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} + run: | + docker run --rm -v $(pwd)/tests/testdata/config.tests.json:/freqtrade/config.json:ro -v $(pwd)/tests:/tests ${CACHE_IMAGE}:${TAG_ARM} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3 + + - name: Docker images + run: | + docker images + + - name: Push cache images + env: + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} + TAG_PLOT_ARM: ${{ steps.tags.outputs.TAG_PLOT_ARM }} + TAG_FREQAI_ARM: ${{ steps.tags.outputs.TAG_FREQAI_ARM }} + TAG_FREQAI_RL_ARM: ${{ steps.tags.outputs.TAG_FREQAI_RL_ARM }} + run: | + docker push ${CACHE_IMAGE}:$TAG_PLOT_ARM + docker push ${CACHE_IMAGE}:$TAG_FREQAI_ARM + docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL_ARM + docker push ${CACHE_IMAGE}:$TAG_ARM + + - name: Create manifests + env: + TAG_ARM: ${{ steps.tags.outputs.TAG_ARM }} + TAG: ${{ steps.tags.outputs.TAG }} + TAG_PI: ${{ steps.tags.outputs.TAG_PI }} + run: | + docker buildx imagetools create \ + --tag ${IMAGE_NAME}:${TAG} \ + --tag ${GHCR_IMAGE_NAME}:${TAG} \ + ${CACHE_IMAGE}:${TAG} ${CACHE_IMAGE}:${TAG_ARM} ${IMAGE_NAME}:${TAG_PI} + + - name: Create multiarch image - Plot + env: + TAG_PLOT: ${{ steps.tags.outputs.TAG_PLOT }} + TAG_PLOT_ARM: ${{ steps.tags.outputs.TAG_PLOT_ARM }} + run: | + docker buildx imagetools create \ + --tag ${IMAGE_NAME}:${TAG_PLOT} \ + --tag ${GHCR_IMAGE_NAME}:${TAG_PLOT} \ + ${CACHE_IMAGE}:${TAG_PLOT} ${CACHE_IMAGE}:${TAG_PLOT_ARM} + + - name: Create multiarch image - FreqAI + env: + TAG_FREQAI: ${{ steps.tags.outputs.TAG_FREQAI }} + TAG_FREQAI_ARM: ${{ steps.tags.outputs.TAG_FREQAI_ARM }} + run: | + docker buildx imagetools create \ + --tag ${IMAGE_NAME}:${TAG_FREQAI} \ + --tag ${GHCR_IMAGE_NAME}:${TAG_FREQAI} \ + ${CACHE_IMAGE}:${TAG_FREQAI} ${CACHE_IMAGE}:${TAG_FREQAI_ARM} + + - name: Create multiarch image - FreqAI RL + env: + TAG_FREQAI_RL: ${{ steps.tags.outputs.TAG_FREQAI_RL }} + TAG_FREQAI_RL_ARM: ${{ steps.tags.outputs.TAG_FREQAI_RL_ARM }} + TAG_FREQAI_TORCH: ${{ steps.tags.outputs.TAG_FREQAI_TORCH }} + run: | + # Create special Torch tag - which is identical to the RL tag. + docker buildx imagetools create \ + --tag ${IMAGE_NAME}:${TAG_FREQAI_RL} \ + --tag ${GHCR_IMAGE_NAME}:${TAG_FREQAI_RL} \ + --tag ${IMAGE_NAME}:${TAG_FREQAI_TORCH} \ + --tag ${GHCR_IMAGE_NAME}:${TAG_FREQAI_TORCH} \ + ${CACHE_IMAGE}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL_ARM} + + - name: Tag latest + if: env.TAG == 'develop' + env: + TAG: ${{ steps.tags.outputs.TAG }} + run: | + # Tag image as latest + docker buildx imagetools create \ + --tag ${GHCR_IMAGE_NAME}:${TAG} \ + --tag ${GHCR_IMAGE_NAME}:latest \ + ${IMAGE_NAME}:${TAG} + + - name: Docker images + run: | + docker images + + - name: Image cleanup + run: | + docker image prune -a --force --filter "until=24h" - name: Discord notification uses: rjstone/discord-webhook-notify@c2597273488aeda841dd1e891321952b51f7996f #v2.2.1 diff --git a/build_helpers/publish_docker_arm64.sh b/build_helpers/publish_docker_arm64.sh deleted file mode 100755 index 990f23e81..000000000 --- a/build_helpers/publish_docker_arm64.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/sh - -# Use BuildKit, otherwise building on ARM fails - -# Replace / with _ to create a valid tag -TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g") -TAG_PLOT=${TAG}_plot -TAG_FREQAI=${TAG}_freqai -TAG_FREQAI_RL=${TAG_FREQAI}rl -TAG_FREQAI_TORCH=${TAG_FREQAI}torch -TAG_PI="${TAG}_pi" - -TAG_ARM=${TAG}_arm -TAG_PLOT_ARM=${TAG_PLOT}_arm -TAG_FREQAI_ARM=${TAG_FREQAI}_arm -TAG_FREQAI_RL_ARM=${TAG_FREQAI_RL}_arm - -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 - -docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG_ARM} -t freqtrade:${TAG_PLOT_ARM} -f docker/Dockerfile.plot . -docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG_ARM} -t freqtrade:${TAG_FREQAI_ARM} -f docker/Dockerfile.freqai . -docker build --build-arg sourceimage=freqtrade --build-arg sourcetag=${TAG_FREQAI_ARM} -t freqtrade:${TAG_FREQAI_RL_ARM} -f docker/Dockerfile.freqai_rl . - -# Tag image for upload and next build step -docker tag freqtrade:$TAG_ARM ${CACHE_IMAGE}:$TAG_ARM -docker tag freqtrade:$TAG_PLOT_ARM ${CACHE_IMAGE}:$TAG_PLOT_ARM -docker tag freqtrade:$TAG_FREQAI_ARM ${CACHE_IMAGE}:$TAG_FREQAI_ARM -docker tag freqtrade:$TAG_FREQAI_RL_ARM ${CACHE_IMAGE}:$TAG_FREQAI_RL_ARM - -# Run backtest -docker run --rm -v $(pwd)/tests/testdata/config.tests.json:/freqtrade/config.json:ro -v $(pwd)/tests:/tests freqtrade:${TAG_ARM} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3 - -if [ $? -ne 0 ]; then - echo "failed running backtest" - return 1 -fi - -docker images - -docker push ${CACHE_IMAGE}:$TAG_PLOT_ARM -docker push ${CACHE_IMAGE}:$TAG_FREQAI_ARM -docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL_ARM -docker push ${CACHE_IMAGE}:$TAG_ARM - -# Create multi-arch image -# Make sure that all images contained here are pushed to github first. -# Otherwise installation might fail. -echo "create manifests" - -docker manifest create ${IMAGE_NAME}:${TAG} ${CACHE_IMAGE}:${TAG} ${CACHE_IMAGE}:${TAG_ARM} ${IMAGE_NAME}:${TAG_PI} -docker manifest push -p ${IMAGE_NAME}:${TAG} - -docker manifest create ${IMAGE_NAME}:${TAG_PLOT} ${CACHE_IMAGE}:${TAG_PLOT} ${CACHE_IMAGE}:${TAG_PLOT_ARM} -docker manifest push -p ${IMAGE_NAME}:${TAG_PLOT} - -docker manifest create ${IMAGE_NAME}:${TAG_FREQAI} ${CACHE_IMAGE}:${TAG_FREQAI} ${CACHE_IMAGE}:${TAG_FREQAI_ARM} -docker manifest push -p ${IMAGE_NAME}:${TAG_FREQAI} - -docker manifest create ${IMAGE_NAME}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL_ARM} -docker manifest push -p ${IMAGE_NAME}:${TAG_FREQAI_RL} - -# Create special Torch tag - which is identical to the RL tag. -docker manifest create ${IMAGE_NAME}:${TAG_FREQAI_TORCH} ${CACHE_IMAGE}:${TAG_FREQAI_RL} ${CACHE_IMAGE}:${TAG_FREQAI_RL_ARM} -docker manifest push -p ${IMAGE_NAME}:${TAG_FREQAI_TORCH} - -# copy images to ghcr.io - -alias crane="docker run --rm -i -v $(pwd)/.crane:/home/nonroot/.docker/ gcr.io/go-containerregistry/crane" -mkdir .crane -chmod a+rwx .crane - -echo "${GHCR_TOKEN}" | crane auth login ghcr.io -u "${GHCR_USERNAME}" --password-stdin - -crane copy ${IMAGE_NAME}:${TAG_FREQAI_RL} ${GHCR_IMAGE_NAME}:${TAG_FREQAI_RL} -crane copy ${IMAGE_NAME}:${TAG_FREQAI_RL} ${GHCR_IMAGE_NAME}:${TAG_FREQAI_TORCH} -crane copy ${IMAGE_NAME}:${TAG_FREQAI} ${GHCR_IMAGE_NAME}:${TAG_FREQAI} -crane copy ${IMAGE_NAME}:${TAG_PLOT} ${GHCR_IMAGE_NAME}:${TAG_PLOT} -crane copy ${IMAGE_NAME}:${TAG} ${GHCR_IMAGE_NAME}:${TAG} - -# Tag as latest for develop builds -if [ "${TAG}" = "develop" ]; then - echo 'Tagging image as latest' - docker manifest create ${IMAGE_NAME}:latest ${CACHE_IMAGE}:${TAG_ARM} ${IMAGE_NAME}:${TAG_PI} ${CACHE_IMAGE}:${TAG} - docker manifest push -p ${IMAGE_NAME}:latest - - crane copy ${IMAGE_NAME}:latest ${GHCR_IMAGE_NAME}:latest -fi - -docker images -rm -rf .crane - -# Cleanup old images from arm64 node. -docker image prune -a --force --filter "until=24h" diff --git a/build_helpers/publish_docker_multi.sh b/build_helpers/publish_docker_multi.sh deleted file mode 100755 index 52dbe7244..000000000 --- a/build_helpers/publish_docker_multi.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# The below assumes a correctly setup docker buildx environment - -# Replace / with _ to create a valid tag -TAG=$(echo "${BRANCH_NAME}" | sed -e "s/\//_/g") -TAG_PLOT=${TAG}_plot -TAG_FREQAI=${TAG}_freqai -TAG_FREQAI_RL=${TAG_FREQAI}rl -TAG_PI="${TAG}_pi" - -PI_PLATFORM="linux/arm/v7" -echo "Running for ${TAG}" -CACHE_TAG=${CACHE_IMAGE}:${TAG_PI}_cache - -# 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} . - # Build PI image - docker buildx build \ - --cache-to=type=registry,ref=${CACHE_TAG} \ - -f docker/Dockerfile.armhf \ - --platform ${PI_PLATFORM} \ - -t ${IMAGE_NAME}:${TAG_PI} \ - --push \ - --provenance=false \ - . -else - echo "event ${GITHUB_EVENT_NAME}: building with cache" - # Build regular image - docker pull ${IMAGE_NAME}:${TAG} - docker build --cache-from ${IMAGE_NAME}:${TAG} -t freqtrade:${TAG} . - - # Pull last build to avoid rebuilding the whole image - # docker pull --platform ${PI_PLATFORM} ${IMAGE_NAME}:${TAG} - # disable provenance due to https://github.com/docker/buildx/issues/1509 - docker buildx build \ - --cache-from=type=registry,ref=${CACHE_TAG} \ - --cache-to=type=registry,ref=${CACHE_TAG} \ - -f docker/Dockerfile.armhf \ - --platform ${PI_PLATFORM} \ - -t ${IMAGE_NAME}:${TAG_PI} \ - --push \ - --provenance=false \ - . -fi - -if [ $? -ne 0 ]; then - echo "failed building multiarch images" - return 1 -fi -# Tag image for upload and next build step -docker tag freqtrade:$TAG ${CACHE_IMAGE}:$TAG - -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 . - -docker tag freqtrade:$TAG_PLOT ${CACHE_IMAGE}:$TAG_PLOT -docker tag freqtrade:$TAG_FREQAI ${CACHE_IMAGE}:$TAG_FREQAI -docker tag freqtrade:$TAG_FREQAI_RL ${CACHE_IMAGE}:$TAG_FREQAI_RL - -# Run backtest -docker run --rm -v $(pwd)/tests/testdata/config.tests.json:/freqtrade/config.json:ro -v $(pwd)/tests:/tests freqtrade:${TAG} backtesting --datadir /tests/testdata --strategy-path /tests/strategy/strats/ --strategy StrategyTestV3 - -if [ $? -ne 0 ]; then - echo "failed running backtest" - return 1 -fi - -docker images - -docker push ${CACHE_IMAGE}:$TAG -docker push ${CACHE_IMAGE}:$TAG_PLOT -docker push ${CACHE_IMAGE}:$TAG_FREQAI -docker push ${CACHE_IMAGE}:$TAG_FREQAI_RL - -docker images - -if [ $? -ne 0 ]; then - echo "failed building image" - return 1 -fi