Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Multiplatform Builds #2549

Open
wants to merge 105 commits into
base: dev/multi-platform-images
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
4cff96b
Add the ability to native build cargo packages
waterfoul Apr 11, 2023
d2d262a
Add --link
waterfoul Apr 11, 2023
8cfee33
Attempting to fix CI
waterfoul Apr 11, 2023
b6a8899
Finished moving pip venvs into cross-compiled layer
waterfoul Apr 12, 2023
9074ee9
Shrinking the dockerfile a bit
waterfoul Apr 13, 2023
360804a
Moving chmod to copy command to reduce layer count
waterfoul Apr 13, 2023
c5b6da9
Add build platform layer, move scalafix to that layer
waterfoul Apr 13, 2023
3ac92b3
Move bash_exec to build_platform
waterfoul Apr 13, 2023
13d9e5c
Move dotenv linter to docker image
waterfoul Apr 13, 2023
51881a7
Added the ability to install into the build-platform stage
waterfoul Apr 13, 2023
a6fa258
Bugfix
waterfoul Apr 13, 2023
99b2782
Bugfix
waterfoul Apr 13, 2023
925606f
Moved megalinter to a venv
waterfoul Apr 13, 2023
08a8073
Add dep
waterfoul Apr 13, 2023
02a8f09
fixed java package, started seperating node modules to it's own layer
waterfoul Apr 13, 2023
8d8ab0c
Fixing node_modules
waterfoul Apr 13, 2023
a571efa
Fixing python
waterfoul Apr 18, 2023
4e45773
Split per platform logic
waterfoul Apr 18, 2023
7c5a220
Tweaking Ruff
waterfoul Apr 18, 2023
1e337b0
debugging
waterfoul Apr 18, 2023
c1ecf9e
Cleanup and debugging
waterfoul Apr 19, 2023
82f2cd5
Adding cache to pip, share the download dir to try to save on downloa…
waterfoul Apr 19, 2023
d9a20a2
Bugfix
waterfoul Apr 19, 2023
e85d55c
Trying to make the download faster
waterfoul Apr 19, 2023
7aba73e
Trying to make the download faster
waterfoul Apr 19, 2023
cb42a56
Tinkering with pip download
waterfoul Apr 19, 2023
87239af
Adjusting pip download
waterfoul Apr 19, 2023
3553551
Bugfix
waterfoul Apr 19, 2023
8fc4d82
Made the dockerfules look cleaner
waterfoul Apr 19, 2023
2fc298a
Broke up the pip installs
waterfoul Apr 19, 2023
591c929
Fix pip, add cargo binstall
waterfoul Apr 19, 2023
53e55fb
Bugfix
waterfoul Apr 19, 2023
18c062e
Bugfix
waterfoul Apr 19, 2023
c85a660
Switch to cargo binstall
waterfoul Apr 20, 2023
538fee8
Bugfix, move ruff to download of binary
waterfoul Apr 20, 2023
71cad60
Bugfix, add log parser script
waterfoul Apr 20, 2023
f198ad6
Debugging
waterfoul Apr 20, 2023
12a7e3e
Debugging
waterfoul Apr 20, 2023
a0b06d6
Add arm64
waterfoul Apr 20, 2023
1bfb687
Starting refactor to make multiarch testing easier
waterfoul Apr 20, 2023
b2405e7
Bugfix
waterfoul Apr 20, 2023
a541ab7
Indent fix
waterfoul Apr 20, 2023
ed81b3f
Indent tweak
waterfoul Apr 20, 2023
fa57dfe
Debugging
waterfoul Apr 20, 2023
dbc5027
Debugging
waterfoul Apr 20, 2023
acd4c95
Debugging
waterfoul Apr 20, 2023
f51f8f4
Indent fix
waterfoul Jul 19, 2023
73d4e83
Debugging
waterfoul Apr 20, 2023
3044104
Debugging
waterfoul Apr 20, 2023
b347bf7
Debugging
waterfoul Apr 20, 2023
5b6b27e
Debugging
waterfoul Apr 20, 2023
05867bd
Debugging
waterfoul Apr 20, 2023
be7eef5
Debugging
waterfoul Apr 20, 2023
ee7aa03
Debugging
waterfoul Apr 20, 2023
9d09516
Reduce retention
waterfoul Apr 20, 2023
77ffbca
Temp remove tar file
waterfoul Apr 20, 2023
513c1c0
Disable arm64
waterfoul Apr 20, 2023
3db4bb3
Adding oci export back
waterfoul Apr 24, 2023
6edec29
Swapping output and arm64
waterfoul Apr 24, 2023
0552f39
Adding the tests back in
waterfoul Apr 24, 2023
c1a5cf3
Bugfix
waterfoul Apr 24, 2023
0f3f713
Bugfix
waterfoul Apr 24, 2023
7a16b90
Bugfix
waterfoul Apr 24, 2023
663a5a4
Bugfix
waterfoul May 15, 2023
b3a28db
Bugfix
waterfoul May 15, 2023
8117096
Test fixes
waterfoul May 15, 2023
13d8863
Delete tar file after loading
waterfoul May 15, 2023
e20c905
Test fix
waterfoul May 17, 2023
6fb1919
Tweaked the python run commands
waterfoul May 17, 2023
b168986
Fix env
waterfoul May 17, 2023
1fd1b01
Bugfix
waterfoul May 18, 2023
5c284d1
Fixed the make file
waterfoul Jul 19, 2023
cc781df
Updating after rebase
waterfoul Jul 19, 2023
e19e90c
Reverting some changes broken by rebase
waterfoul Jul 19, 2023
c547732
Reverting some changes broken by rebase
waterfoul Jul 19, 2023
35eb8c9
Reverting some changes broken by rebase
waterfoul Jul 19, 2023
1aa3fa8
Fixing CI
waterfoul Jul 19, 2023
c329665
Fixing CI
waterfoul Jul 19, 2023
43c6cd3
Fixing CI
waterfoul Jul 19, 2023
bc06bdd
Fixing CI
waterfoul Jul 19, 2023
ab071fc
Pull in dockerfile changes lost in rebase
waterfoul Jul 19, 2023
b04c606
Switch a base image
waterfoul Jul 19, 2023
5e96026
Enable arm
waterfoul Jul 19, 2023
48a46c6
Moved revive build to cross compile
waterfoul Jul 20, 2023
f0a05a3
Move dustilock to cross compile
waterfoul Jul 20, 2023
43d9378
Bugfix
waterfoul Jul 20, 2023
891a99e
Add wheel
waterfoul Jul 20, 2023
ea0cd80
Sped up the build a bit
waterfoul Jul 24, 2023
4e568bd
Bugfix
waterfoul Jul 24, 2023
77c9137
Bugfix
waterfoul Jul 24, 2023
c127f10
Fix luacheck install
waterfoul Jul 25, 2023
db79f5e
Splitting out the run command temporarially to check build times
waterfoul Jul 25, 2023
691ac58
Attempting to update to new salesforce cli which should be smaller
waterfoul Jul 25, 2023
3db704d
Move phive to build platform
waterfoul Jul 25, 2023
d24b5ba
Move arm-ttk to build platform
waterfoul Jul 25, 2023
3e3d4df
Bugfix
waterfoul Jul 25, 2023
460bc76
Fixed musl wheels
waterfoul Jul 25, 2023
f7ee3cb
Break down a run command to see wqhere the time is being spent
waterfoul Jul 26, 2023
f171b77
Remove sdfx-hardis
waterfoul Jul 26, 2023
e7ed3ed
Fix a bug in the ide extension code
waterfoul Jul 26, 2023
546966d
Debugging
waterfoul Jul 26, 2023
560dc8c
Disabled powershell for arm
waterfoul Jul 26, 2023
79f607e
Bugfix
waterfoul Jul 26, 2023
c811e52
Reenable amd64
waterfoul Jul 26, 2023
8a809c9
Increase build space using action
waterfoul Jul 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 231 additions & 61 deletions .automation/build.py

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions .config/make/python.mak
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ python-bootstrap-dev: ## Bootstrap python for dev env
# ===============================================================================================
.PHONY: python-venv-init
python-venv-init: ## Create venv ".venv/" if not exist
if [ ! -d .venv ] ; then
$(python_launcher) -m venv .venv
if [[ ! -d .venv ]] ; then \
$(python_launcher) -m venv .venv; \
fi

.PHONY: python-venv-upgrade
python-venv-upgrade: ## Upgrade venv with pip, setuptools and wheel
source .venv/bin/activate
. .venv/bin/activate; \
pip install --upgrade pip setuptools wheel

.PHONY: python-venv-requirements
python-venv-requirements: ## Install or upgrade from $(python_requirements_file)
source .venv/bin/activate
. .venv/bin/activate; \
pip install --upgrade --requirement $(python_requirements_file)

.PHONY: python-venv-requirements-dev
python-venv-requirements-dev: ## Install or upgrade from $(python_requirements_dev_file)
source .venv/bin/activate
. .venv/bin/activate; \
pip install --upgrade --requirement $(python_requirements_dev_file)

.PHONY: python-venv-linters-install
python-venv-linters-install: ## Install or upgrade linters
source .venv/bin/activate
. .venv/bin/activate; \
pip install --upgrade flake8

.PHONY: python-venv-purge
Expand All @@ -54,22 +54,22 @@ python-venv-purge: ## Remove venv ".venv/" folder
.PHONY: python-purge-cache
python-purge-cache: ## Purge cache to avoid used cached files
if [ -d .venv ] ; then
source .venv/bin/activate
. .venv/bin/activate; \
pip cache purge
fi

.PHONY: python-version
python-version: ## Displays the python version used for the .venv
source .venv/bin/activate
. .venv/bin/activate; \
$(python_launcher) --version

.PHONY: python-flake8
python-flake8: ## Run flake8 linter for python
source .venv/bin/activate
. .venv/bin/activate; \
flake8 --config .config/.flake8

.PHONY: python-pytest
python-pytest: ## Run pytest to test python scripts
source .venv/bin/activate
. .venv/bin/activate; \
cd scripts/
$(python_launcher) -m pytest
131 changes: 131 additions & 0 deletions .github/workflows/-build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: "Build Docker"

on:
workflow_call:
inputs:
tagTemplate:
required: true
type: string
shouldLoginDockerHub:
required: true
type: boolean
shouldLoginGithub:
required: true
type: boolean
dockerfile:
required: true
type: string
push:
required: true
type: boolean
imageName:
required: true
type: string
workerImageName:
required: true
type: string

jobs:
build:
name: Build Docker
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 512
swap-size-mb: 1024
remove-dotnet: 'true' # will release about 17GB if you don't need .NET
remove-haskell: 'true' # will release about 2.7GB if you don't need haskell
remove-android: 'true' # will release about 11 GB if you don't need Android
remove-codeql: 'true' # will release about 5.4GB if you don't need CodeQL
remove-docker-images: 'true' # will free about 3GB by clearing out some pre cached images
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>"$GITHUB_ENV"

- name: Build image tag name
id: image_tag
run: |
BRANCH_NAME="${GITHUB_REF##*/}"
TAG="${{ inputs.tagTemplate }}"
echo "Tag name: ${TAG}"
MAIN_TAG=()
WORKER_TAG=()
if [[ "${{inputs.shouldLoginGithub}}" == "true" ]]; then
MAIN_TAG+=("ghcr.io/oxsecurity/${{ inputs.imageName }}:${TAG}")
WORKER_TAG+=("ghcr.io/oxsecurity/${{ inputs.workerImageName }}:${TAG}")
fi
if [[ "${{inputs.shouldLoginDockerHub}}" == "true" ]]; then
MAIN_TAG+=("oxsecurity/${{ inputs.imageName }}:${TAG}")
WORKER_TAG+=("oxsecurity/${{ inputs.workerImageName }}:${TAG}")
fi
echo "tag=${MAIN_TAG}" >>"$GITHUB_OUTPUT"
echo "workerTag=${WORKER_TAG}" >>"$GITHUB_OUTPUT"

- name: Login to Docker Hub
if: ${{ inputs.shouldLoginDockerHub }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

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

- name: Build Image
uses: docker/build-push-action@v4
with:
file: ${{ inputs.dockerfile }}
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=alpha
load: false
push: ${{ inputs.push }}
outputs: ${{ (!inputs.push && 'type=oci,dest=image.tar') || '' }}

secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.image_tag.outputs.tag }}

- name: Build Worker Image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile-worker
platforms: linux/amd64
build-args: |
MEGALINTER_BASE_IMAGE=ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=alpha
load: false
push: ${{ inputs.push }}

secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: ${{ steps.image_tag.outputs.workerTag }}

- name: Archive oci artifacts
uses: actions/upload-artifact@v3
with:
name: oci-tar
path: image.tar
if-no-files-found: ${{ (inputs.push && 'ignore') || 'error' }}
retention-days: 1
76 changes: 13 additions & 63 deletions .github/workflows/deploy-ALPHA-flavors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ jobs:
build:
# Name the Job
name: Deploy Docker Image - ALPHA - Flavors
# Set the agent to run on
runs-on: ${{ matrix.os }}
permissions:
packages: write
# Only run this on the main repo
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
uses: ./.github/workflows/-build-docker.yml
with:
tagTemplate: "alpha"
shouldLoginDockerHub: false
shouldLoginGithub: true
dockerfile: flavors/${{ matrix.flavor }}/Dockerfile
push: true
imageName: megalinter-${{ matrix.flavor }}
workerImageName: megalinter-worker-${{ matrix.flavor }}
strategy:
fail-fast: false
max-parallel: 10
matrix:
os: [ubuntu-latest]
# flavors-start
flavor:
[
Expand All @@ -70,77 +78,19 @@ jobs:
"swift",
"terraform",
]
# flavors-end
# Only run this on the main repo
if: github.repository == 'oxsecurity/megalinter' && !contains(github.event.head_commit.message, 'skip deploy')
# flavors-end
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

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

- name: Get current date
run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> ${GITHUB_ENV}

- name: Build Image
uses: docker/build-push-action@v4
with:
context: .
file: flavors/${{ matrix.flavor }}/Dockerfile
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=alpha
load: false
push: true
secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha

- name: Build Worker Image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile-worker
platforms: linux/amd64
build-args: |
MEGALINTER_BASE_IMAGE=ghcr.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_REVISION=${{ github.sha }}
BUILD_VERSION=alpha
load: false
push: true
secrets: |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
tags: |
ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:alpha

##############################################
# Check Docker image security with Trivy #
##############################################
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'ghcr.io/oxsecurity/megalinter-worker-${{ matrix.flavor }}:alpha'
image-ref: 'docker.io/oxsecurity/megalinter-${{ matrix.flavor }}:alpha'
format: 'table'
exit-code: '1'
ignore-unfixed: true
Expand Down
Loading