From d983b6095daa0d1aef5c33dc0d0558c77dfff098 Mon Sep 17 00:00:00 2001
From: Noah Harasz <ndharasz@live.com>
Date: Wed, 2 Oct 2024 19:14:52 -0700
Subject: [PATCH] add bash shell version of the image

---
 .github/workflows/deploy-shell.yaml | 71 +++++++++++++++++++++++++++++
 Makefile                            | 12 +++++
 shell/Dockerfile                    | 16 +++++++
 3 files changed, 99 insertions(+)
 create mode 100644 .github/workflows/deploy-shell.yaml
 create mode 100644 shell/Dockerfile

diff --git a/.github/workflows/deploy-shell.yaml b/.github/workflows/deploy-shell.yaml
new file mode 100644
index 0000000..f01d52c
--- /dev/null
+++ b/.github/workflows/deploy-shell.yaml
@@ -0,0 +1,71 @@
+name: Deploy Python 3.11 Image
+
+env:
+  REGISTRY: ghcr.io
+  IMAGE_NAME: numerai_predict
+
+on:
+  workflow_dispatch:
+  push:
+    branches:
+      - master
+
+jobs:
+  public-py311-image:
+    runs-on: ubuntu-latest
+    permissions:
+      packages: write
+      contents: read
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Extract short git SHA
+        run: echo "GIT_REF=`git rev-parse --short HEAD`" >> $GITHUB_ENV
+
+      - name: Log in to Github Container registry
+        uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
+        with:
+          registry: ${{ env.REGISTRY }}
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Extract metadata (tags, labels) for Docker
+        id: meta
+        uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
+        with:
+          images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}_shell
+
+      - name: Push Docker image as LATEST to Github Container registry
+        uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
+        with:
+          context: .
+          file: ./py3.11/Dockerfile
+          push: true
+          tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}_shell:latest
+          labels: ${{ steps.meta.outputs.labels }}
+
+      - name: Push Docker image git ref to Github Container registry
+        uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
+        with:
+          context: .
+          file: ./py3.11/Dockerfile
+          push: true
+          tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}_shell:${{ env.GIT_REF }}
+          labels: ${{ steps.meta.outputs.labels }}
+
+  internal-py311-image:
+    runs-on: ubuntu-latest
+    permissions:
+      id-token: write
+      contents: read
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Configure AWS Credentials
+        uses: aws-actions/configure-aws-credentials@v4
+        with:
+          role-to-assume: arn:aws:iam::${{ secrets.MODEL_UPLOADS_ACCOUNT_ID }}:role/github-actions
+          aws-region: us-west-2
+
+      - name: Build and Push Docker Image
+        run: ACCOUNT_ID=${{ secrets.MODEL_UPLOADS_ACCOUNT_ID }} make push_latest_shell
diff --git a/Makefile b/Makefile
index 78edb67..ebcdf49 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,10 @@ build_3_10: ## Build Python 3.10 container
 build_3_11: ## Build Python 3.11 container
 	docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_py_3_11:${GIT_REF} -t ${NAME}_py_3_11:latest -f py3.11/Dockerfile .
 
+.PHONY: build_shell
+build_shell: ## Build Python 3.11 container
+	docker build --build-arg GIT_REF=${GIT_REF} -t ${NAME}_shell:${GIT_REF} -t ${NAME}_shell:latest -f shell/Dockerfile .
+
 .PHONY: test
 test: test_3_9 test_3_10 test_3_11 ## Test all container versions
 
@@ -71,6 +75,14 @@ push_latest_3_11: build_3_11## Release Python 3.11 contianer tagged latest
 	docker push ${ECR_REPO}/${NAME}_py_3_11:${GIT_REF}
 	docker push ${ECR_REPO}/${NAME}_py_3_11:latest
 
+.PHONY: push_latest_shell
+push_latest_shell: build_shell## Release Python 3.11 contianer tagged latest
+	aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin ${ECR_REPO}
+	docker tag ${NAME}_shell:${GIT_REF} ${ECR_REPO}/${NAME}_shell:${GIT_REF}
+	docker tag ${NAME}_shell:latest ${ECR_REPO}/${NAME}_shell:latest
+	docker push ${ECR_REPO}/${NAME}_shell:${GIT_REF}
+	docker push ${ECR_REPO}/${NAME}_shell:latest
+
 .PHONY: push_stable
 push_stable: push_stable_3_9 push_stable_3_10 push_stable_3_11 ## Push all container tagged stable
 
diff --git a/shell/Dockerfile b/shell/Dockerfile
new file mode 100644
index 0000000..4da9e14
--- /dev/null
+++ b/shell/Dockerfile
@@ -0,0 +1,16 @@
+FROM python:3.11-slim
+
+ARG GIT_REF
+ENV GIT_REF=$GIT_REF
+RUN apt-get update -yqq \
+    && apt-get install -yqq --no-install-recommends \
+    build-essential \
+    cmake \
+    git \
+    python3-dev
+
+COPY ./requirements.txt .
+RUN pip install --upgrade pip
+RUN pip install -r requirements.txt
+
+COPY ./predict.py .