diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..8866a21 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,45 @@ +name: Build Docker Image + +on: + workflow_dispatch: + inputs: + use_local_freesurfer: + type: boolean + description: 'Use local FreeSurfer binaries instead of downloading' + required: false + default: false + push_to_registry: + type: boolean + description: 'Push the built image to Docker registry' + required: false + default: false + push: + branches: [ main, master ] + tags: [ 'v*' ] + pull_request: + branches: [ main, master ] + +jobs: + build-docker: + runs-on: self-hosted + name: Build Docker Image + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build Docker image + run: | + export DOCKER_BUILDKIT=0 + echo "Debug: Project name extraction:" + cat pyproject.toml | grep '^name =' | cut -d '"' -f 2 + echo "Debug: Version extraction:" + cat pyproject.toml | grep '^version =' | cut -d '"' -f 2 + echo "Debug: Full command that will be run:" + echo "docker build --build-arg=\"USE_LOCAL_FREESURFER=${{ github.event.inputs.use_local_freesurfer || 'False' }}\" -t openneuropet/$(cat pyproject.toml | grep '^name =' | cut -d '"' -f 2):$(cat pyproject.toml | grep '^version =' | cut -d '"' -f 2) ." + make dockerbuild USE_LOCAL_FREESURFER=${{ github.event.inputs.use_local_freesurfer || 'False' }} + + - name: Push Docker image + if: github.event.inputs.push_to_registry == 'true' || startsWith(github.ref, 'refs/tags/') + run: | + make dockerpush \ No newline at end of file diff --git a/Makefile b/Makefile index b213466..b752c48 100644 --- a/Makefile +++ b/Makefile @@ -27,12 +27,12 @@ pythondeps: USE_LOCAL_FREESURFER ?= False dockerbuild: - docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t openneuropet/$(shell cat pyproject.toml | grep name | cut -d '"' -f 2):$(shell cat pyproject.toml | grep version | head -n 1 | cut -d '"' -f 2) . - docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t openneuropet/$(shell cat pyproject.toml | grep name | cut -d '"' -f 2):latest . + docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t openneuropet/$(shell cat pyproject.toml | grep '^name =' | cut -d '"' -f 2):$(shell cat pyproject.toml | grep '^version =' | cut -d '"' -f 2) . + docker build --build-arg="USE_LOCAL_FREESURFER=$(USE_LOCAL_FREESURFER)" -t openneuropet/$(shell cat pyproject.toml | grep '^name =' | cut -d '"' -f 2):latest . dockerpush: dockerbuild - docker push openneuropet/$(shell cat pyproject.toml | grep name | cut -d '"' -f 2):$(shell cat pyproject.toml | grep version | head -n 1 | cut -d '"' -f 2) - docker push openneuropet/$(shell cat pyproject.toml | grep name | cut -d '"' -f 2):latest + docker push openneuropet/$(shell cat pyproject.toml | grep '^name =' | cut -d '"' -f 2):$(shell cat pyproject.toml | grep '^version =' | cut -d '"' -f 2) + docker push openneuropet/$(shell cat pyproject.toml | grep '^name =' | cut -d '"' -f 2):latest html: cd docs && make html \ No newline at end of file