Skip to content

Commit

Permalink
👷 Update docker builds
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwoerpel committed Nov 12, 2024
1 parent 3806dd9 commit ea17340
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 140 deletions.
120 changes: 74 additions & 46 deletions .github/workflows/build-ui.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,85 @@
name: Build UI
name: Build aleph ui

on:
workflow_dispatch: {}
push:
paths-ignore:
- "aleph/**"
- "contrib/**"
- "helm/**"
- "mappings/**"
- "site/**"
- "docs/**"
- "requirements.txt"
- "requirements-dev.txt"
paths:
- aleph-ui/*
- .github/workflows/aleph-ui.yml

permissions:
packages: write

jobs:
build:
docker-base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/investigativedata/aleph-ui-base
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push release
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Setup
run: echo "ALEPH_SECRET=batman\n" >> aleph.env

- name: Build development image
run: |
docker build -t ghcr.io/alephdata/aleph-ui:${GITHUB_SHA} ui
docker tag ghcr.io/alephdata/aleph-ui:${GITHUB_SHA} ghcr.io/alephdata/aleph-ui:latest
- name: Check code formatting
run: make format-check-ui

- name: Run linter
run: make lint-ui

- name: Run tests
run: make test-ui

- name: Build production image
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: docker build -t ghcr.io/alephdata/aleph-ui-production:${GITHUB_SHA} -f ui/Dockerfile.production ui

- name: Push docker image (tagged)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
export ALEPH_TAG=${GITHUB_REF/refs\/tags\//}
docker tag ghcr.io/alephdata/aleph-ui-production:${GITHUB_SHA} ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG};
docker push ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG};
- name: Tag latest image
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && !startsWith(github.ref, 'refs/tags/test-')
run: |
docker tag ghcr.io/alephdata/aleph-ui-production:${GITHUB_SHA} ghcr.io/alephdata/aleph-ui-production:latest;
docker push ghcr.io/alephdata/aleph-ui-production:latest;
docker:
needs: docker-base
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/investigativedata/aleph-ui
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push release
uses: docker/build-push-action@v3
with:
context: ./aleph-ui
build-args: |
ALEPH_TAG=${{ version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
81 changes: 35 additions & 46 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build
name: Build aleph

on:
workflow_dispatch: {}
push:
paths-ignore:
- "ui/**"
Expand All @@ -10,50 +11,38 @@ permissions:
packages: write

jobs:
build:
docker:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up
run: |
sudo sysctl -w vm.max_map_count=262144
sudo echo "ALEPH_SECRET=batman\n" >> aleph.env
echo "${GITHUB_REF}"
docker --version
docker-compose --version
- name: Docker pull services
run: |
docker-compose pull --quiet elasticsearch ingest-file
make ALEPH_TAG=${GITHUB_SHA} services
- name: Build docker image
run: docker build -t ghcr.io/alephdata/aleph:${GITHUB_SHA} .

- name: Install development dependencies
run: make dev

- name: Check code formatting
run: make format-check

- name: Run linter
run: make lint

- name: Run aleph tests
run: make ALEPH_TAG=${GITHUB_SHA} test

- name: Push docker images for tags
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
export ALEPH_TAG=${GITHUB_REF/refs\/tags\//}
docker tag ghcr.io/alephdata/aleph:${GITHUB_SHA} ghcr.io/alephdata/aleph:${ALEPH_TAG};
docker push ghcr.io/alephdata/aleph:${ALEPH_TAG};
- name: Tag latest image
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && !startsWith(github.ref, 'refs/tags/test-')
run: |
docker tag ghcr.io/alephdata/aleph:${GITHUB_SHA} ghcr.io/alephdata/aleph:latest;
docker push ghcr.io/alephdata/aleph:latest;
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/investigativedata/aleph
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push release
uses: docker/build-push-action@v3
with:
context: .
# platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
48 changes: 0 additions & 48 deletions .github/workflows/docker.yml

This file was deleted.

0 comments on commit ea17340

Please sign in to comment.