diff --git a/.github/workflows/docker-image-arm.yml b/.github/workflows/docker-image-arm.yml new file mode 100644 index 00000000..d6418cbb --- /dev/null +++ b/.github/workflows/docker-image-arm.yml @@ -0,0 +1,51 @@ +name: build-and-upload-docker-image-arm + +on: + push: + branches: + - 'main' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}_arm + + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + context: . + push: true + platforms: linux/arm64 + file: DockerfileArm + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/DockerfileArm b/DockerfileArm new file mode 100644 index 00000000..0ab1435e --- /dev/null +++ b/DockerfileArm @@ -0,0 +1,54 @@ +# __ __ ____ +# | \/ | ___ _ __ ___ ___ _ __ _ _/ ___| ___ ___ _ __ ___ +# | |\/| |/ _ \ '_ ` _ \ / _ \| '__| | | \___ \ / __/ _ \| '_ \ / _ \ +# | | | | __/ | | | | | (_) | | | |_| |___) | (_| (_) | |_) | __/ +# |_| |_|\___|_| |_| |_|\___/|_| \__, |____/ \___\___/| .__/ \___| +# |___/ |_| + +# Instruction + +# To construct docker image: +# sudo docker build --network=host -t memoryscope . + +# To run docker image: +# sudo docker run -it --rm --memory=4G --net=host memoryscope +# To run docker image with arguments (refer to memoryscope/core/config/arguments.py): +# sudo docker run -it --rm --memory=4G --net=host -e "OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -e "language=en" -e "human_name=superman" -e "generation_backend=openai_generation" -e "generation_model=gpt-4o" -e "embedding_backend=openai_embedding" -e "embedding_model=text-embedding-3-small" -e "enable_ranker=False" memoryscope + +FROM python:3.11 + +# (Not necessary) Change pip source +RUN echo '[global]' > /etc/pip.conf && \ + echo 'index-url = https://mirrors.aliyun.com/pypi/simple/' >> /etc/pip.conf && \ + echo 'trusted-host = mirrors.aliyun.com' >> /etc/pip.conf + +# Install Elastic Search +RUN useradd -m elastic_search_user +USER elastic_search_user +WORKDIR /home/elastic_search_user/elastic_search +RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.2-linux-aarch64.tar.gz +RUN tar -xzf elasticsearch-8.15.2-linux-aarch64.tar.gz +WORKDIR /home/elastic_search_user/elastic_search/elasticsearch-8.15.2 +ENV DISCOVERY_TYPE=single-node \ + XPACK_SECURITY_ENABLED=false \ + XPACK_LICENSE_SELF_GENERATED_TYPE=trial + +# Change user back to root and fix ownership +USER root +RUN chown -R elastic_search_user:elastic_search_user /home/elastic_search_user/ +WORKDIR /memory_scope_project + +# (Not necessary) Install the majority of deps, using docker build cache to accelerate future building +COPY requirements.txt ./ +RUN pip3 install -r requirements.txt + +# Enter working dir +WORKDIR /memory_scope_project +COPY . . +# RUN pip3 install poetry +# RUN poetry install +RUN pip3 install -r requirements.txt + +# Launch! +# CMD ["bash"] +CMD ["bash", "examples/docker/entrypoint.sh"] \ No newline at end of file