diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27c453c..7b858c2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,17 +12,41 @@ on: permissions: - contents: read + contents: write id-token: write packages: write jobs: - build: + release: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: + - futu + - moomoo + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-build + cancel-in-progress: true + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v3 + + - name: Create Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: startsWith(github.ref, 'refs/tags/') + with: + draft: false + prerelease: false + name: ${{ github.ref_name }} + tag_name: ${{ github.ref_name }} + + futu: runs-on: ubuntu-latest timeout-minutes: 30 concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-build + group: ${{ github.workflow }}-${{ github.ref }}-futu cancel-in-progress: true steps: @@ -40,7 +64,8 @@ jobs: uses: docker/metadata-action@v4 with: images: | - ghcr.io/${{ github.repository }} + ghcr.io/chasenlabs/futu-opend + ghcr.io/chasenlabs/futunn tags: | type=ref,event=branch type=ref,event=pr @@ -54,9 +79,62 @@ jobs: with: context: . file: ./Dockerfile + build-args: | + BRAND=Futu + DOMAIN=futunn.com + BIN_NAME=FutuOpenD push: true tags: ${{ steps.meta.outputs.tags }} labels: | org.opencontainers.image.title=futu-opend org.opencontainers.image.description=The futu-opend image org.opencontainers.image.source=github.com/${{ github.repository }} + + + moomoo: + runs-on: ubuntu-latest + timeout-minutes: 30 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-moomoo + cancel-in-progress: true + + steps: + - uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/chasenlabs/moomoo-opend + ghcr.io/chasenlabs/moomoo + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=${{ github.run_id }} + type=raw,value=latest + + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + build-args: | + BRAND=moomoo + DOMAIN=futustatic.com + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.title=moomoo-opend + org.opencontainers.image.description=The moomoo-opend image + org.opencontainers.image.source=github.com/${{ github.repository }} diff --git a/Dockerfile b/Dockerfile index d6b30c1..651f445 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,27 @@ FROM ubuntu:22.04 -# metadata -LABEL maintainer="ChasenLbas " -LABEL description="Futu OpenD Docker Image" +ARG BRAND=unspecified +ARG DOMAIN=unspecified +ARG BUILD_OPEND_VERSION=8.6.4608 +ARG OPEND_DIR=/opend +ARG BIN_NAME=OpenD -ENV LANG C.UTF-8 +# metadata +LABEL org.opencontainers.image.maintainer="ChasenLbas " +LABEL org.opencontainers.image.description="${BRAND} OpenD Docker Image" -# Futu_OpenD_8.6.4608_Ubuntu16.04.tar.gz -ENV OPEND_VERSION 8.6.4608 -ENV OPEND_FILE Futu_OpenD_${OPEND_VERSION}_Ubuntu16.04.tar.gz -ENV OPEND_DIR /opend -ENV OPEND_PREFIX Futu_OpenD_${OPEND_VERSION}_Ubuntu16.04 +# xxxx_OpenD_8.6.4608_Ubuntu16.04.tar.gz +ARG OPEND_PREFIX=${BRAND}_OpenD_${BUILD_OPEND_VERSION}_Ubuntu16.04 +ARG OPEND_FILE=${OPEND_PREFIX}.tar.gz # Download OpenD package # https://softwaredownload.futunn.com/Futu_OpenD_8.6.4608_Ubuntu16.04.tar.gz -ENV OPEND_URL https://softwaredownload.futunn.com/${OPEND_FILE} +# https://softwaredownload.futustatic.com/moomoo_OpenD_8.6.4608_Ubuntu16.04.tar.gz +ARG OPEND_URL=https://softwaredownload.${DOMAIN}/${OPEND_FILE} + +ENV OPEND_VERSION ${BUILD_OPEND_VERSION} +ENV LANG C.UTF-8 +ENV OPEND_BIN ${OPEND_DIR}/${BIN_NAME} COPY docker-entrypoint.sh . @@ -24,8 +31,8 @@ RUN apt-get update && apt-get install -y \ curl \ tar \ telnet \ - && curl -o /tmp/futu-opend.tar.gz ${OPEND_URL} \ - && tar -zxvf /tmp/futu-opend.tar.gz -C /tmp/ \ + && curl -o /tmp/opend.tar.gz ${OPEND_URL} \ + && tar -zxvf /tmp/opend.tar.gz -C /tmp/ \ && mkdir -p ${OPEND_DIR} \ && ls /tmp/ \ && cp -r /tmp/${OPEND_PREFIX}/${OPEND_PREFIX}/* ${OPEND_DIR} \ diff --git a/README.md b/README.md index 907cd37..4151fc5 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,35 @@ # Futu OpenD +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/chasenlabs/futu-opend/main.yml) +![GitHub last commit (branch)](https://img.shields.io/github/last-commit/chasenlabs/futu-opend) +![GitHub Release Date](https://img.shields.io/github/release-date/chasenlabs/futu-opend) +![GitHub Release](https://img.shields.io/github/v/release/chasenlabs/futu-opend?&color=fff) +![](https://img.shields.io/badge/futu-opend-ff6900.svg?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxOTYuNzIgMTk2LjcyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzMyMzQzOTt9LmNscy0ze2ZpbGw6I2ZmNjkwMDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmljb24tbml1bml1LWVuX25ldzwvdGl0bGU+PGcgaWQ9ImxheWVyLTEiIGRhdGEtbmFtZT0ibGF5ZXItMSI+PGNpcmNsZSBjbGFzcz0iY2xzLTEiIGN4PSI5OC4zNiIgY3k9Ijk4LjM2IiByPSI5OC4zNiIvPjxwYXRoIGN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wzLjMzLDlhMSwxLDAsMCwwLDEuODItLjA3bDMuMjgtMTEuODNhMi41OSwyLjU5LDAsMCwwLTIuMTUtMy4yNmwtMzguNTEtNS4xNGMtMjcuNDktMy42OC0zMi40LTQxLjM2LTYuNzctNTJsNy4zMy0zYTEsMSwwLDAsMSwxLjI4LDEuNDZsLTYuMjQsMTAuNTVhMTQsMTQsMCwwLDAsMTAuMiwyMWw0My4xLDUuNzZhMTEuMywxMS4zLDAsMCwwLDExLjU5LTE2LjI4TDIwMywzMi4yOGMtMjIuNDMtNDQuNi04Ni44LTQyLjUzLTEwNi4zMywzLjQybC0xLjIxLDIuODZMNDguMTIsMTUwLjA1QTIuNjQsMi42NCwwLDAsMCw1MC41NSwxNTMuNzJaIi8+CiAgICAgICAgPHBhdGggY2xhc3M9ImNscy0yIiBkPSJNMjEzLjUsNzYuNzNsNC0uNjVhMjIuMzUsMjIuMzUsMCwwLDAsMTIuNzItMzcuM2wtNi45My03YTEuMDcsMS4wNywwLDAsMC0xLjc3LDEuMDlsMy4wNyw5YTEwLjY2LDEwLjY2LDAsMCwxLTUsMTNoMFoiLz4KICAgIDwvZz4KPC9zdmc+&logoColor=ff6900) -using docker to run Futu OpenD +使用docker运行**富途OpenD**,并且每天自动检查更新到最新版。 -- [OpenAPI](https://www.futunn.com/OpenAPI) +Using docker to run **Futu OpenD / moomoo OpenD** and automatically update to the latest version daily. +- [Futu OpenAPI](https://www.futunn.com/OpenAPI) +- [moomoo OpenAPI](https://openapi.moomoo.com/moomoo-api-doc) ```shell -docker pull ghcr.io/chasenlabs/futu-opend:latest +docker pull ghcr.io/chasenlabs/futu-opend:latest # futu +docker pull ghcr.io/chasenlabs/moomoo-opend:latest # moomoo ``` +> [!IMPORTANT] +> This project is not officially supported by Futu, and the author is not responsible for any problems caused by the use of this project. +> +> 这个项目不是富途官方支持的,作者对使用这个项目造成的任何问题不负责任。 + ## Configuration run command in docker container, or see [Futu API](https://openapi.futunn.com/futu-api-doc/opend/opend-cmd.html#8799) ```shell -cat FutuOpend.xml +cat FutuOpenD.xml # fufu +cat OpenD.xml # moomoo ``` md5 your password @@ -25,32 +40,53 @@ md5 -s ## Example -**Using docker-compose start** - -启动之前请配置运行参数[docker-compose.yml](docker-compose.yml) +using docker-compose start -start before config [docker-compose.yml](docker-compose.yml) +启动之前请配置运行参数 [docker-compose](docker-compose.yml) / start before config [docker-compose](docker-compose.yml) ```shell docker-compose up ``` -**输入手机验证码/Enter mobile phone verification code**, [docs is here](https://openapi.futunn.com/futu-api-doc/opend/opend-operate.html#815) +or using docker run, more parameters see [Start with command](https://openapi.futunn.com/futu-api-doc/opend/opend-cmd.html#465) + +```shell +# futu +docker run -d --name opend -p 11111:11111 ghcr.io/chasenlabs/futu-opend:latest \ + /docker-entrypoint.sh \ + -login_account= \ + -login_pwd_md5= \ + -api_port=11111 \ + -api_ip=0.0.0.0 \ + -telnet_port=22222 \ + -lang=chs +# moomoo +docker run -d --name opend -p 11111:11111 ghcr.io/chasenlabs/moomoo-opend:latest \ + /docker-entrypoint.sh \ + -login_account= \ + -login_pwd_md5= \ + -api_port=11111 \ + -api_ip=0.0.0.0 \ + -telnet_port=22222 \ + -lang=en +``` + +输入手机验证码 / enter mobile phone verification code, [ops docs is here](https://openapi.futunn.com/futu-api-doc/opend/opend-operate.html#815) ```shell -docker exec -it futu-opend bash +docker exec -it opend bash # syntax: telnet telnet 127.0.0.1 22222 input_phone_verify_code -code= ``` -**Prepare** +testing prepare ```shell pip install -r requirements.txt # if you located in China, you can use aliyun mirror to speed up pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ ``` -**get data with main.py** +testing with main.py ```shell python main.py --addr ``` diff --git a/docker-compose.yml b/docker-compose.yml index 6c146c4..520d21f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ services: - futu-opend: + opend: image: ghcr.io/chasenlabs/futu-opend:latest + #image: ghcr.io/chasenlabs/moomoo-opend:latest # moomoo container_name: futu-opend restart: unless-stopped ports: @@ -9,6 +10,7 @@ services: # https://openapi.futunn.com/futu-api-doc/opend/opend-cmd.html#8799 volumes: - ./FutuOpenD.xml:/opend/FutuOpenD.xml +# - ./OpenD.xml:/opend/OpenD.xml # moomoo # or https://openapi.futunn.com/futu-api-doc/opend/opend-cmd.html#465 # command: # - /docker-entrypoint.sh @@ -17,4 +19,4 @@ services: # - -api_port=11111 # - -api_ip=0.0.0.0 # - -telnet_port=22222 -# - -lang=en=en +# - -lang=en diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d2f7fcd..878bac9 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,10 +2,8 @@ set -x -echo "Futu OpenD Install Dir: $OPEND_DIR" - -BIN="$OPEND_DIR/FutuOpenD" +echo "Futu OpenD Install Dir: ${OPEND_BIN}" # Start OpenD -echo "Starting OpenD..." -exec "${BIN}" "$@" \ No newline at end of file +echo "Starting ${OPEND_BIN}..." +exec "${OPEND_BIN}" "$@"