diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..dc63c0a --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,36 @@ +name: Build and push image to ECR +on: + push: + branches: + - master + + + +jobs: + build-and-push-ecr-image: + name: Build Image + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Install Utilities + run: | + sudo apt-get update + sudo apt-get install -y jq unzip + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: GemstonePricePrediction + IMAGE_TAG: latest + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eb65d5d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.9-slim-buster +WORKDIR /service +COPY requirements.txt . +COPY . ./ +RUN pip install -r requirements.txt +ENTRYPOINT ["python3", "app.py"] \ No newline at end of file diff --git a/app.py b/app.py index 55f552a..8acec5d 100644 --- a/app.py +++ b/app.py @@ -37,4 +37,4 @@ def predict_datapoint(): if __name__ == "__main__": - app.run(port=5001, debug=True) + app.run(host="0.0.0.0", port=8080) diff --git a/template.py b/template.py index 033885d..ae69e9b 100644 --- a/template.py +++ b/template.py @@ -5,6 +5,8 @@ list_of_files = [ ".github/workflows/.gitkeep", + ".github/workflows/main.yaml", + "Dockerfile", f"src/{package_name}/__init__.py", f"src/{package_name}/components/__init__.py", f"src/{package_name}/components/data_ingestion.py",