Skip to content

Commit

Permalink
Merge pull request #386 from mikeyavorsky/move-backend-to-graviton
Browse files Browse the repository at this point in the history
Build ARM & Intel images for back-end
  • Loading branch information
mikeyavorsky authored Jun 4, 2024
2 parents 53fca53 + 91635c5 commit 77eca3f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 26 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/aws-ecs-deploy-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
AWS_REGION: us-east-1
DOCKERFILE: ./backend/Dockerfile.cloud
DOCKER_PATH: ./
PLATFORMS: linux/amd64,linux/arm64
jobs:
setup_env:
name: Set-up environment
Expand Down Expand Up @@ -66,20 +67,22 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build & Push Image to ECR
uses: kciter/aws-ecr-action@v5
- name: Login to ECR
uses: docker/login-action@v3
with:
registry: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
account_id: ${{ secrets.AWS_ACCOUNT_ID }}
repo: ${{ needs.setup_env.outputs.AWS_APPENV }}
region: ${{ env.AWS_REGION }}
tags: latest,${{ needs.setup_env.outputs.IMAGE_TAG }}
dockerfile: ${{ env.DOCKERFILE }}
path: ${{ env.DOCKER_PATH }}
context: ${{ env.DOCKER_PATH }}
file: ${{ env.DOCKERFILE }}
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ needs.setup_env.outputs.AWS_APPENV }}:${{ needs.setup_env.outputs.IMAGE_TAG }}, ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ needs.setup_env.outputs.AWS_APPENV }}:latest
deploy:
name: Deploy to AWS ECS
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions backend/Dockerfile.cloud
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
FROM python:3-slim-bullseye

# required for pandas
RUN apt-get update -y && apt-get install gcc g++ python3-dev -y
RUN apt-get update -y && apt-get install gcc g++ python3-dev wget -y

WORKDIR /app/

ARG PDT_API_PORT=5000

COPY requirements/prod.txt .
RUN pip install -r prod.txt
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN arch=$(arch) && \
file=pandas-2.2.2-cp312-cp312-manylinux_2_17_${arch}.manylinux2014_${arch}.whl && \
url="https://pypi.debian.net/pandas/${file}" && \
wget ${url} && \
sed -i "s/pandas==1.5.3/${file}/" prod.txt
RUN pip install --no-cache-dir -r prod.txt

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion requirements/_core.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ flake8
flask
flask-sqlalchemy
gunicorn
pandas
pandas==2.2.2
pip-tools
pydantic
pydantic-sqlalchemy
Expand Down
8 changes: 5 additions & 3 deletions requirements/dev_unix.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/dev_unix.in
Expand Down Expand Up @@ -308,7 +308,7 @@ packaging==24.0
# pytest-flask-sqlalchemy
# qtconsole
# qtpy
pandas==1.5.3
pandas==2.2.2
# via -r requirements/_core.in
pandocfilters==1.5.1
# via nbconvert
Expand Down Expand Up @@ -523,7 +523,9 @@ typing-extensions==4.10.0
# psycopg
# pydantic
tzdata==2024.1
# via celery
# via
# celery
# pandas
ua-parser==0.18.0
# via -r requirements/_core.in
uri-template==1.3.0
Expand Down
8 changes: 5 additions & 3 deletions requirements/dev_windows.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/dev_windows.in
Expand Down Expand Up @@ -308,7 +308,7 @@ packaging==24.0
# pytest-flask-sqlalchemy
# qtconsole
# qtpy
pandas==1.5.3
pandas==2.2.2
# via -r requirements/_core.in
pandocfilters==1.5.1
# via nbconvert
Expand Down Expand Up @@ -523,7 +523,9 @@ typing-extensions==4.10.0
# psycopg
# pydantic
tzdata==2024.1
# via celery
# via
# celery
# pandas
ua-parser==0.18.0
# via -r requirements/_core.in
uri-template==1.3.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/docs.in
Expand Down
8 changes: 5 additions & 3 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.11
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/prod.in
Expand Down Expand Up @@ -308,7 +308,7 @@ packaging==24.0
# pytest-flask-sqlalchemy
# qtconsole
# qtpy
pandas==1.5.3
pandas==2.2.2
# via -r requirements/_core.in
pandocfilters==1.5.1
# via nbconvert
Expand Down Expand Up @@ -523,7 +523,9 @@ typing-extensions==4.10.0
# psycopg
# pydantic
tzdata==2024.1
# via celery
# via
# celery
# pandas
ua-parser==0.18.0
# via -r requirements/_core.in
uri-template==1.3.0
Expand Down

0 comments on commit 77eca3f

Please sign in to comment.