diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..96b847f --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,35 @@ +name: Publish Docker + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + publish_docker_image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Login to Container Registry + uses: docker/login-action@v3 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALIYUN_REGISTRY_USERNAME }} + password: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }} + + - name: Build, tag, and push the image to Aliyun registry + id: build-image + env: + ALIYUN_REGISTRY: "registry.cn-hangzhou.aliyuncs.com" + ALIYUN_REPOSITORY: kenplusplus/gentrade_server + IMAGE_TAG: ${{ env.RELEASE_VERSION }} + run: | + docker build --no-cache -t $ALIYUN_REGISTRY/$ALIYUN_REPOSITORY:$IMAGE_TAG . + docker push $ALIYUN_REGISTRY/$ALIYUN_REPOSITORY:$IMAGE_TAG + docker tag $ALIYUN_REGISTRY/$ALIYUN_REPOSITORY:$IMAGE_TAG $ALIYUN_REGISTRY/$ALIYUN_REPOSITORY:latest + docker push $ALIYUN_REGISTRY/$ALIYUN_REPOSITORY:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4994dbf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:22.04 + +RUN apt update -y && apt install -y python3 python3-pip git && apt clean -y + +ENV PIP_MIRROR="-i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple" +ENV GENTRADE_CACHE_DIR="/app/cache/" + +ADD . /app/GenTradeServer +RUN git clone https://github.com/TrustWiseAgent/GenTrade /app/GenTrade + +ENV PYTHONPATH=/app/GenTrade/src/:/app/GenTradeServer/src/ + +VOLUME [ "/app/cache/" ] +WORKDIR /app/GenTradeServer/src/ + +RUN pip install ${PIP_MIRROR} -r /app/GenTrade/requirements.txt +RUN pip install ${PIP_MIRROR} -r /app/GenTradeServer/requirements.txt + + +EXPOSE 8000 + +ENTRYPOINT [ "uvicorn", "gentrade_server.main:app", \ + "--host", "0.0.0.0", \ + "--port", "8000" ]