Skip to content

Commit

Permalink
feat: arm64 builds, updated actions dependencies (#352)
Browse files Browse the repository at this point in the history
* feat: arm64 builds, updated actions dependencies

* test: split RUN command to fix buildx error

* debug: arch

* test: remove image hash

* revert: Dockerfile

* test: multi staged builds

* revert: Dockerfile
  • Loading branch information
nimish-ks authored Sep 4, 2024
1 parent 4af7b98 commit b14c8c7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 48 deletions.
102 changes: 57 additions & 45 deletions .github/workflows/docker_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

Expand All @@ -28,7 +28,7 @@ jobs:
run: echo "::set-output name=sha::$(git rev-parse --verify HEAD | cut -c 1-7)"

- name: Set Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "18"

Expand All @@ -43,40 +43,44 @@ jobs:
yarn test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push frontend
id: docker_build_frontend
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ steps.short_sha.outputs.sha }}, ghcr.io/${{ github.repository }}/frontend:${{ steps.short_sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ steps.short_sha.outputs.sha }}
ghcr.io/${{ github.repository }}/frontend:${{ steps.short_sha.outputs.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push backend
id: docker_build_backend
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ steps.short_sha.outputs.sha }}, ghcr.io/${{ github.repository }}/backend:${{ steps.short_sha.outputs.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ steps.short_sha.outputs.sha }}
ghcr.io/${{ github.repository }}/backend:${{ steps.short_sha.outputs.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

push:
runs-on: ubuntu-latest
Expand All @@ -85,10 +89,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "18"

Expand All @@ -103,51 +107,55 @@ jobs:
yarn test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push frontend
id: docker_build_frontend_main
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest, ghcr.io/${{ github.repository }}/frontend:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
ghcr.io/${{ github.repository }}/frontend:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push backend
id: docker_build_backend_main
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/backend:latest, ghcr.io/${{ github.repository }}/backend:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/backend:latest
ghcr.io/${{ github.repository }}/backend:latest
cache-from: type=gha
cache-to: type=gha,mode=max

release:
runs-on: ubuntu-latest
if: github.event_name == 'release'

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set Node.js environment
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: "18"

Expand All @@ -162,37 +170,41 @@ jobs:
yarn test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push frontend
id: docker_build_frontend_release
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./frontend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.event.release.tag_name }}, ghcr.io/${{ github.repository }}/frontend:${{ github.event.release.tag_name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/frontend:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}/frontend:${{ github.event.release.tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Build and push backend
id: docker_build_backend_release
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: ./backend
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.event.release.tag_name }}, ghcr.io/${{ github.repository }}/backend:${{ github.event.release.tag_name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/backend:${{ github.event.release.tag_name }}
ghcr.io/${{ github.repository }}/backend:${{ github.event.release.tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 3 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM python:3.12.1-alpine3.19@sha256:28230397c48cf4e2619822beb834ae7e46ebcd255b8f7cef58eff932fd75d2ce
# Stage 1: Build dependencies
FROM python:3.12.1-alpine3.19

ADD requirements.txt /app/requirements.txt
ADD constraints.txt /app/constraints.txt
Expand Down Expand Up @@ -29,5 +30,4 @@ ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

EXPOSE 8000

CMD sh -c "python manage.py migrate && gunicorn --bind :8000 --workers 3 backend.wsgi:application"
CMD ["sh", "-c", "python manage.py migrate && gunicorn --bind :8000 --workers 3 backend.wsgi:application"]

0 comments on commit b14c8c7

Please sign in to comment.