Skip to content

Commit

Permalink
[docker][fix] Fix out of space error (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
lloesche committed Jul 24, 2023
1 parent 46a197e commit df5b1ca
Show file tree
Hide file tree
Showing 3 changed files with 275 additions and 20 deletions.
271 changes: 271 additions & 0 deletions .github/workflows/docker-build-arm.yml
@@ -0,0 +1,271 @@
name: Build Docker Images

on:
push:
tags:
- "*.*.*"
branches:
- main
pull_request:
paths:
- "Dockerfile*"
- "docker/**"
- "dockerV2/**"
- ".github/workflows/docker-build-arm.yml"

jobs:
split-build:
name: "Build ARM64 Docker images"
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Get short commit SHA
id: sha
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- name: Create swap for ARM builds
if: github.ref_type == 'tag' # on tagging of releases and prereleases
run: |
echo "Creating 20GB swap files for ARM builds"
sudo swapoff -a
sudo rm -f /mnt/swapfile
time sudo dd if=/dev/zero of=/mnt/swapfile bs=13M count=1000
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
time sudo dd if=/dev/zero of=/swapfile bs=7M count=1000
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -m
- name: Set build platforms
id: platform
run: |
GITHUB_REF="${{ github.ref }}"
GITHUB_TAG=${GITHUB_REF##*/}
if [ "${{ github.ref_type }}" = tag ]; then
echo "targets=linux/arm64" >> $GITHUB_OUTPUT
echo "uitag=latest" >> $GITHUB_OUTPUT
if [[ "$GITHUB_TAG" =~ [0-9]([ab]|rc)[0-9]* ]]; then
echo "latest=false" >> $GITHUB_OUTPUT
else
echo "latest=true" >> $GITHUB_OUTPUT
fi
else
echo "targets=linux/arm64" >> $GITHUB_OUTPUT
echo "uitag=edge" >> $GITHUB_OUTPUT
echo "latest=false" >> $GITHUB_OUTPUT
fi
- name: Check short commit SHA and build targets
run: |
echo ${{ steps.sha.outputs.short }}
echo ${{ steps.platform.outputs.targets }}
echo ${{ steps.platform.outputs.uitag }}
echo ${{ steps.platform.outputs.latest }}
- name: Docker resotobase meta
id: basemeta
uses: docker/metadata-action@v4
with:
images: |
someengineering/resotobase
ghcr.io/someengineering/resotobase
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=resotobase
org.opencontainers.image.description=Resoto base image
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Docker resotocore meta
if: github.event_name != 'pull_request'
id: coremeta
uses: docker/metadata-action@v3
with:
images: |
someengineering/resotocore
ghcr.io/someengineering/resotocore
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=resotocore
org.opencontainers.image.description=Resoto Core
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Docker resotoworker meta
if: github.event_name != 'pull_request'
id: workermeta
uses: docker/metadata-action@v4
with:
images: |
someengineering/resotoworker
ghcr.io/someengineering/resotoworker
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=resotoworker
org.opencontainers.image.description=Resoto Worker
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Docker resotometrics meta
if: github.event_name != 'pull_request'
id: metricsmeta
uses: docker/metadata-action@v4
with:
images: |
someengineering/resotometrics
ghcr.io/someengineering/resotometrics
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=resotometrics
org.opencontainers.image.description=Resoto Metrics
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Docker resotoshell meta
if: github.event_name != 'pull_request'
id: shellmeta
uses: docker/metadata-action@v4
with:
images: |
someengineering/resotoshell
someengineering/resh
ghcr.io/someengineering/resotoshell
ghcr.io/someengineering/resh
flavor: |
latest=${{ steps.platform.outputs.latest }}
tags: |
type=pep440,pattern={{version}}
type=pep440,pattern={{major}}.{{minor}}
type=pep440,pattern={{major}}
type=sha,prefix=
type=edge
labels: |
org.opencontainers.image.title=resotoshell
org.opencontainers.image.description=Resoto Shell (resh)
org.opencontainers.image.vendor=Some Engineering Inc.
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64,amd64

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

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}

- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push resotobase Docker image
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.resotobase
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
UI_IMAGE_TAG=${{ steps.platform.outputs.uitag }}
SOURCE_COMMIT=${{ github.sha }}
TESTS=false
tags: ${{ steps.basemeta.outputs.tags }}
labels: ${{ steps.basemeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533

- name: Build and push resotocore Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.resotocore
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
IMAGE_TAG=${{ steps.sha.outputs.short }}
tags: ${{ steps.coremeta.outputs.tags }}
labels: ${{ steps.coremeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533

- name: Build and push resotoworker Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.resotoworker
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
IMAGE_TAG=${{ steps.sha.outputs.short }}
tags: ${{ steps.workermeta.outputs.tags }}
labels: ${{ steps.workermeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533

- name: Build and push resotometrics Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.resotometrics
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
IMAGE_TAG=${{ steps.sha.outputs.short }}
tags: ${{ steps.metricsmeta.outputs.tags }}
labels: ${{ steps.metricsmeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533

- name: Build and push resotoshell Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile.resotoshell
platforms: ${{ steps.platform.outputs.targets }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
IMAGE_TAG=${{ steps.sha.outputs.short }}
tags: ${{ steps.shellmeta.outputs.tags }}
labels: ${{ steps.shellmeta.outputs.labels }}
provenance: false # Temporary workaround for https://github.com/docker/buildx/issues/1533
20 changes: 2 additions & 18 deletions .github/workflows/docker-build.yml
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
split-build:
name: "Build split Docker images" # Do not rename without updating workflow defined in publish.yml
name: "Build x86_64 Docker images" # Do not rename without updating workflow defined in publish.yml
runs-on: ubuntu-latest

steps:
Expand All @@ -27,29 +27,13 @@ jobs:
id: sha
run: echo "short=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT

- name: Create swap for ARM builds
if: github.ref_type == 'tag' # on tagging of releases and prereleases
run: |
echo "Creating 20GB swap files for ARM builds"
sudo swapoff -a
sudo rm -f /mnt/swapfile
time sudo dd if=/dev/zero of=/mnt/swapfile bs=10M count=1000
sudo chmod 600 /mnt/swapfile
sudo mkswap /mnt/swapfile
sudo swapon /mnt/swapfile
time sudo dd if=/dev/zero of=/swapfile bs=10M count=1000
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -m
- name: Set build platforms
id: platform
run: |
GITHUB_REF="${{ github.ref }}"
GITHUB_TAG=${GITHUB_REF##*/}
if [ "${{ github.ref_type }}" = tag ]; then
echo "targets=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
echo "targets=linux/amd64" >> $GITHUB_OUTPUT
echo "uitag=latest" >> $GITHUB_OUTPUT
if [[ "$GITHUB_TAG" =~ [0-9]([ab]|rc)[0-9]* ]]; then
echo "latest=false" >> $GITHUB_OUTPUT
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Expand Up @@ -83,7 +83,7 @@ jobs:
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ github.ref }}
check-name: Build split Docker images
check-name: Build x86_64 Docker images
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Update resource data models
Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
uses: lewagon/wait-on-check-action@v1.3.1
with:
ref: ${{ github.ref }}
check-name: Build split Docker images
check-name: Build x86_64 Docker images
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Update resource data models
Expand Down

0 comments on commit df5b1ca

Please sign in to comment.