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

Automate building Docker container images #570

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
@@ -0,0 +1,5 @@
deploy/**
.git/**
Dockerfile
.devcontainer/**
.github/**
98 changes: 98 additions & 0 deletions .github/workflows/docker.yaml
@@ -0,0 +1,98 @@
name: Docker Builds

on:
push:
branches:
- master
tags:
- "v*"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Docker Metadata (light target)
id: metadata_light
uses: docker/metadata-action@v3.6.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
flavor: |
suffix=-light,onlatest=true
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge

- name: Docker Metadata (full target)
id: metadata
uses: docker/metadata-action@v3.6.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=edge

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

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

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

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build and push (light target)
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
target: light
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/riscv64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata_light.outputs.tags }}
labels: ${{ steps.metadata_light.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# building the full version could be done in a separate workflow,
# but using the same instance allows reusing the light target as a base
- name: Build and push (full target)
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/riscv64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache-new
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
36 changes: 36 additions & 0 deletions Dockerfile
@@ -0,0 +1,36 @@
FROM ubuntu:20.04 as light

LABEL org.opencontainers.image.authors="Phoronix Media <commercial@phoronix-test-suite.com>"


ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
apt-file\
apt-utils\
git-core\
php-cli\
php-xml\
sudo\
unzip\
&& rm -rf /var/lib/apt/lists/*


WORKDIR /app/

# copy in files
COPY . /app/

RUN ./phoronix-test-suite make-openbenchmarking-cache lean \
&& rm -f /var/lib/phoronix-test-suite/core.pt2so

CMD ["./phoronix-test-suite", "shell"]


FROM light as full

# install extra packages commonly used by tests
RUN apt-get update && apt-get install -y \
build-essential\
autoconf\
&& rm -rf /var/lib/apt/lists/*