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

GHA: Docker build refactor #6396

Merged
merged 49 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
02498d2
CI: WIP: Refactore docker build
danielhollas Apr 23, 2024
7ab005a
Remove pre-commit from requirements
danielhollas Apr 23, 2024
29768ad
Add docker-test
danielhollas Apr 23, 2024
b141d5b
Docker publish
danielhollas Apr 23, 2024
967b637
Initial build workflow
danielhollas Apr 23, 2024
e64965a
remove action
danielhollas Apr 23, 2024
afe8448
Merge branch 'aiidateam:main' into docker-refactor
danielhollas May 13, 2024
fc00eb0
Updates from aiidalab stack
danielhollas May 13, 2024
0bada85
Merge branch 'main' into docker-refactor
danielhollas May 16, 2024
9c0c257
Fix test-amd64
danielhollas May 16, 2024
e16c127
One more fix
danielhollas May 16, 2024
f088c29
Don't run ci-code on push
danielhollas May 16, 2024
9491a2e
workdir
danielhollas May 16, 2024
d470378
Fix test-install?
danielhollas May 16, 2024
8a2941d
Build only amd64
danielhollas May 16, 2024
6c4fe7b
Docker: Pintesting environment
danielhollas May 16, 2024
6d71fc0
Build amd64 first
danielhollas May 21, 2024
ff0c49f
Add target option to pytest
danielhollas May 21, 2024
a9e6290
wtf
danielhollas May 21, 2024
d8b979c
Fix
danielhollas May 21, 2024
8f4e7cb
Merge branch 'main' into docker-refactor
danielhollas May 21, 2024
9f9b694
Full build needs test-amd64
danielhollas May 21, 2024
4c906c0
Fix
danielhollas May 21, 2024
d9443f5
Fix docker-compose files
danielhollas May 21, 2024
2fe8562
update uv
danielhollas May 22, 2024
eb69696
Fix test-install.yml test
danielhollas May 22, 2024
a06b549
Decrease timeout
danielhollas May 22, 2024
b7f8136
Fix comments in Dockerfile
danielhollas May 22, 2024
fad7c28
Temporarily enable arm64 testing
danielhollas May 22, 2024
115b2f4
Update comments
danielhollas May 22, 2024
13f69c2
Downgrade pytest
danielhollas May 22, 2024
cc4bd58
Fix ARM tests
danielhollas May 22, 2024
c420452
Revert "Temporarily enable arm64 testing"
danielhollas May 22, 2024
608aff8
Increase timeout again
danielhollas May 22, 2024
ab2ebd1
Revert "Fix test-install.yml test"
danielhollas May 22, 2024
f5d125e
revert test-install fix
danielhollas May 22, 2024
0130717
Don't run on forks for now
danielhollas May 22, 2024
09931e9
Merge branch 'main' into docker-refactor
danielhollas May 22, 2024
57f209d
Update .github/workflows/extract-docker-image-names.sh
danielhollas May 24, 2024
2f92c27
Merge branch 'main' into docker-refactor
danielhollas May 24, 2024
5d0c012
warp
danielhollas May 25, 2024
49a0b09
Skip Docker build for PRs from forks
danielhollas May 25, 2024
ec12d50
Skip Docker build for PRs from forks
danielhollas May 25, 2024
ed3621a
Test arm on branch
danielhollas May 25, 2024
cb6f1fe
Revert "Test arm on branch"
danielhollas May 25, 2024
b53ff48
Revert "warp"
danielhollas May 25, 2024
c9c5cd6
Merge branch 'main' into docker-refactor
danielhollas May 27, 2024
f0a9a94
revert ci-code change
danielhollas May 27, 2024
bd9cc39
Consistent path-ignore in docker.yml
danielhollas May 27, 2024
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
6 changes: 3 additions & 3 deletions .docker/aiida-core-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1

# Inspired by jupyter's docker-stacks-fundation image:
# https://github.com/jupyter/docker-stacks/blob/main/docker-stacks-foundation/Dockerfile
# https://github.com/jupyter/docker-stacks/tree/main/images/docker-stacks-foundation/Dockerfile

ARG BASE=ubuntu:22.04

Expand Down Expand Up @@ -87,7 +87,7 @@ RUN sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashr
# Add call to conda init script see https://stackoverflow.com/a/58081608/4413446
echo 'eval "$(command conda shell.bash hook 2> /dev/null)"' >> /etc/skel/.bashrc

# Create SYSTEM_USER with name jovyan user with UID=1000 and in the 'users' group
# Create $SYSTEM_USER user with UID=1000 and 'users' group
# and make sure these dirs are writable by the `users` group.
RUN echo "auth requisite pam_deny.so" >> /etc/pam.d/su && \
sed -i.bak -e 's/^%admin/#%admin/' /etc/sudoers && \
Expand All @@ -112,7 +112,7 @@ ARG MAMBA_VERSION
# Similar projects using Micromamba:
# - Micromamba-Docker: <https://github.com/mamba-org/micromamba-docker>
# - repo2docker: <https://github.com/jupyterhub/repo2docker>
# Install Python, Mamba and jupyter_core
# Install Python, Mamba
# Cleanup temporary files and remove Micromamba
# Correct permissions
# Do all this in a single RUN command to avoid duplicating all of the
Expand Down
4 changes: 2 additions & 2 deletions .docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variable "ORGANIZATION" {
}

variable "REGISTRY" {
default = "docker.io/"
default = "ghcr.io/"
}

variable "PLATFORMS" {
Expand All @@ -27,7 +27,7 @@ variable "TARGETS" {
function "tags" {
params = [image]
result = [
"${REGISTRY}${ORGANIZATION}/${image}:newly-baked"
"${REGISTRY}${ORGANIZATION}/${image}"
]
}

Expand Down
2 changes: 1 addition & 1 deletion .docker/docker-compose.aiida-core-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
retries: 10

aiida:
image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-base}:${TAG:-latest}
image: ${REGISTRY:-}${AIIDA_CORE_BASE_IMAGE:-aiidateam/aiida-core-base}${TAG:-}
environment:
RMQHOST: messaging
TZ: Europe/Zurich
Expand Down
2 changes: 1 addition & 1 deletion .docker/docker-compose.aiida-core-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.4'
services:

aiida:
image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-dev}:${TAG:-latest}
image: ${REGISTRY:-}${AIIDA_CORE_DEV_IMAGE:-aiidateam/aiida-core-dev}${TAG:-}
environment:
TZ: Europe/Zurich
SETUP_DEFAULT_AIIDA_PROFILE: 'true'
2 changes: 1 addition & 1 deletion .docker/docker-compose.aiida-core-with-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.4'
services:

aiida:
image: ${REGISTRY:-}${BASE_IMAGE:-aiidateam/aiida-core-with-services}:${TAG:-latest}
image: ${REGISTRY:-}${AIIDA_CORE_WITH_SERVICES_IMAGE:-aiidateam/aiida-core-with-services}${TAG:-}
environment:
TZ: Europe/Zurich
SETUP_DEFAULT_AIIDA_PROFILE: 'true'
Expand Down
2 changes: 1 addition & 1 deletion .docker/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
minversion = 7.0
addopts = -ra -q
addopts = -ra -q --strict-markers
testpaths =
tests
12 changes: 4 additions & 8 deletions .docker/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
docker
pre-commit
pytest
requests
tabulate
pytest-docker
docker-compose
pyyaml<=5.3.1
docker~=7.0.0
pytest~=8.2.0
requests~=2.32.0
pytest-docker~=3.1.0
34 changes: 23 additions & 11 deletions .docker/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,33 @@

import pytest

TARGETS = ('aiida-core-base', 'aiida-core-with-services', 'aiida-core-dev')

@pytest.fixture(
scope='session',
params=[
'aiida-core-base',
'aiida-core-with-services',
'aiida-core-dev',
],
)
def variant(request):
return request.param

def target_checker(value):
msg = f"Invalid image target '{value}', must be one of: {TARGETS}"
if value not in TARGETS:
raise pytest.UsageError(msg)
return value


def pytest_addoption(parser):
parser.addoption(
'--variant',
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use --target here to be consistent with aiidalab-docker-stack but I'll do that in a separate PR.

action='store',
required=True,
help='target (image name) of the docker-compose file to use.',
type=target_checker,
)


@pytest.fixture(scope='session')
def variant(pytestconfig):
return pytestconfig.getoption('variant')


@pytest.fixture(scope='session')
def docker_compose_file(pytestconfig, variant):
def docker_compose_file(variant):
return f'docker-compose.{variant}.yml'


Expand Down
26 changes: 0 additions & 26 deletions .github/actions/create-dev-env/action.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/actions/install-aiida-core/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
- name: Install uv installer
run: curl --proto '=https' --tlsv1.2 -LsSf https://${{ env.UV_URL }} | sh
env:
UV_VERSION: 0.1.35
UV_VERSION: 0.1.44
UV_URL: github.com/astral-sh/uv/releases/download/$UV_VERSION/uv-installer.sh
shell: bash

Expand Down
30 changes: 0 additions & 30 deletions .github/actions/load-image/action.yml

This file was deleted.

83 changes: 0 additions & 83 deletions .github/workflows/docker-build-test-upload.yml

This file was deleted.

77 changes: 77 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Build Docker images and upload them to ghcr.io

env:
BUILDKIT_PROGRESS: plain

on:
workflow_call:
inputs:
runsOn:
description: GitHub Actions Runner image
required: true
type: string
platforms:
description: Target platforms for the build (linux/amd64 and/or linux/arm64)
required: true
type: string
outputs:
images:
description: Images identified by digests
value: ${{ jobs.build.outputs.images }}

jobs:
build:
name: ${{ inputs.platforms }}
runs-on: ${{ inputs.runsOn }}
timeout-minutes: 60
defaults:
run:
# Make sure we fail if any command in a piped command sequence fails
shell: bash -e -o pipefail {0}

outputs:
images: ${{ steps.bake_metadata.outputs.images }}

steps:

- name: Checkout Repo ⚡️
uses: actions/checkout@v4

- name: Set up QEMU
if: ${{ inputs.platforms != 'linux/amd64' }}
uses: docker/setup-qemu-action@v3

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

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

- name: Build and upload to ghcr.io 📤
id: build
uses: docker/bake-action@v4
with:
push: true
workdir: .docker/
# Using provenance to disable default attestation so it will build only desired images:
# https://github.com/orgs/community/discussions/45969
provenance: false
set: |
*.platform=${{ inputs.platforms }}
*.output=type=registry,push-by-digest=true,name-canonical=true
*.cache-to=type=gha,scope=${{ github.workflow }},mode=max
*.cache-from=type=gha,scope=${{ github.workflow }}
files: |
docker-bake.hcl
build.json

- name: Set output variables
id: bake_metadata
run: |
.github/workflows/extract-docker-image-names.sh | tee -a "${GITHUB_OUTPUT}"
env:
BAKE_METADATA: ${{ steps.build.outputs.metadata }}
Loading
Loading