From 42a52ff6694c4595e27df7f3c49accb7ae3448c8 Mon Sep 17 00:00:00 2001 From: Boris Pruessmann Date: Sat, 1 May 2021 14:13:21 +0200 Subject: [PATCH 1/2] Docker support for arm64 --- Dockerfile.aarch64 | 58 +++++++++++++++++++++++++++++++++ build_helpers/install_ta-lib.sh | 5 ++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.aarch64 diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 new file mode 100644 index 000000000..71c10d949 --- /dev/null +++ b/Dockerfile.aarch64 @@ -0,0 +1,58 @@ +FROM --platform=linux/arm64/v8 python:3.9.4-slim-buster as base + +# Setup env +ENV LANG C.UTF-8 +ENV LC_ALL C.UTF-8 +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONFAULTHANDLER 1 +ENV PATH=/home/ftuser/.local/bin:$PATH +ENV FT_APP_ENV="docker" + +# Prepare environment +RUN mkdir /freqtrade \ + && apt-get update \ + && apt-get -y install libatlas3-base curl sqlite3 libhdf5-serial-dev sudo \ + && apt-get clean \ + && useradd -u 1000 -G sudo -U -m ftuser \ + && chown ftuser:ftuser /freqtrade \ + # Allow sudoers + && echo "ftuser ALL=(ALL) NOPASSWD: /bin/chown" >> /etc/sudoers + +WORKDIR /freqtrade + +# Install dependencies +FROM base as python-deps +RUN apt-get update \ + && apt-get -y install curl build-essential libssl-dev git libffi-dev libgfortran5 pkg-config cmake gcc \ + && apt-get clean \ + && pip install --upgrade pip + +# Install TA-lib +COPY build_helpers/* /tmp/ +RUN cd /tmp && /tmp/install_ta-lib.sh && rm -r /tmp/*ta-lib* +ENV LD_LIBRARY_PATH /usr/local/lib + +# Install dependencies +COPY --chown=ftuser:ftuser requirements.txt requirements-hyperopt.txt /freqtrade/ +USER ftuser +RUN pip install --user --no-cache-dir numpy \ + && pip install --user --no-cache-dir -r requirements-hyperopt.txt + +# Copy dependencies to runtime-image +FROM base as runtime-image +COPY --from=python-deps /usr/local/lib /usr/local/lib +ENV LD_LIBRARY_PATH /usr/local/lib + +COPY --from=python-deps --chown=ftuser:ftuser /home/ftuser/.local /home/ftuser/.local + +USER ftuser +# Install and execute +COPY --chown=ftuser:ftuser . /freqtrade/ + +RUN pip install -e . --user --no-cache-dir \ + && mkdir /freqtrade/user_data/ \ + && freqtrade install-ui + +ENTRYPOINT ["freqtrade"] +# Default to trade mode +CMD [ "trade" ] diff --git a/build_helpers/install_ta-lib.sh b/build_helpers/install_ta-lib.sh index cb86e5f64..dd87cf105 100755 --- a/build_helpers/install_ta-lib.sh +++ b/build_helpers/install_ta-lib.sh @@ -8,10 +8,13 @@ if [ ! -f "${INSTALL_LOC}/lib/libta_lib.a" ]; then tar zxvf ta-lib-0.4.0-src.tar.gz cd ta-lib \ && sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h \ + && curl 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' -o config.guess \ + && curl 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' -o config.sub \ && ./configure --prefix=${INSTALL_LOC}/ \ - && make \ + && make -j$(nproc) \ && which sudo && sudo make install || make install \ && cd .. else echo "TA-lib already installed, skipping installation" fi +# && sed -i.bak "s|0.00000001|0.000000000000000001 |g" src/ta_func/ta_utility.h \ From 70189b19920bfaf705196fa3e0da72d89967ac43 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 May 2021 17:24:41 +0200 Subject: [PATCH 2/2] Move dockerfile and document M1 image existance --- .../Dockerfile.aarch64 | 0 docs/docker_quickstart.md | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+) rename Dockerfile.aarch64 => docker/Dockerfile.aarch64 (100%) diff --git a/Dockerfile.aarch64 b/docker/Dockerfile.aarch64 similarity index 100% rename from Dockerfile.aarch64 rename to docker/Dockerfile.aarch64 diff --git a/docs/docker_quickstart.md b/docs/docker_quickstart.md index 5f48782d2..8d8582609 100644 --- a/docs/docker_quickstart.md +++ b/docs/docker_quickstart.md @@ -48,6 +48,8 @@ Create a new directory and place the [docker-compose file](https://raw.githubuse # Download the docker-compose file from the repository curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml + # Edit the compose file to use an image named `*_pi` (stable_pi or develop_pi) + # Pull the freqtrade image docker-compose pull @@ -65,6 +67,30 @@ Create a new directory and place the [docker-compose file](https://raw.githubuse # image: freqtradeorg/freqtrade:develop_pi ``` +=== "ARM64 (Mac M1)" + Make sure that your docker installation is running in native mode + + ``` bash + mkdir ft_userdata + cd ft_userdata/ + # Download the docker-compose file from the repository + curl https://raw.githubusercontent.com/freqtrade/freqtrade/stable/docker-compose.yml -o docker-compose.yml + + # Edit the compose file, uncomment the "build" step and use "./docker/Dockerfile.aarch64" + # Also, change the image name to something of your liking + + # Build the freqtrade image (this may take a while) + docker-compose build + + # Create user directory structure + docker-compose run --rm freqtrade create-userdir --userdir user_data + + # Create configuration - Requires answering interactive questions + docker-compose run --rm freqtrade new-config --config user_data/config.json + ``` + !!! Warning + You should not use the default image name - this can result in conflicting names between local and dockerhub and should therefore be avoided. + The above snippet creates a new directory called `ft_userdata`, downloads the latest compose file and pulls the freqtrade image. The last 2 steps in the snippet create the directory with `user_data`, as well as (interactively) the default configuration based on your selections.