Skip to content

Commit

Permalink
Merge pull request #203 from kaitj/enh/docker
Browse files Browse the repository at this point in the history
Add fastsurfer docker + workflow
  • Loading branch information
kaitj authored Feb 17, 2025
2 parents d74b7b0 + 4cc353c commit 9d9cef9
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/deploy-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Deploy container to DockerHub

on:
workflow_dispatch:

jobs:
docker-deploy:
name: Docker Deploy
runs-on: ubuntu-latest

steps:
- name: Maximize build space
uses: easimon/maximize-build-space@v10
with:
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
overprovision-lvm: 'true'

- uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Check, build, and push Docker images
run: |
# Function to check if tag exists in DockerHub
check_tag_exists() {
local image_name=$1
local tag=$2
# Get Docker Hub token
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
-d "{\"username\": \"${{ secrets.DOCKERHUB_USERNAME }}\", \"password\": \"${{ secrets.DOCKERHUB_TOKEN }}\"}" \
https://hub.docker.com/v2/users/login/ | jq -r .token)
# Check if the tag exists
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Authorization: JWT ${TOKEN}" \
"https://hub.docker.com/v2/repositories/${image_name}/tags/${tag}/")
if [ "$HTTP_CODE" -eq 200 ]; then
return 0 # Tag exists
fi
return 1 # Tag does not exist
}
# For each package descriptor in the packages directory
pushd packages > /dev/null
for json_file in *.json; do
# Get the package name
package_name="$(json_file%.json)"
# Check if corresponding dockerfile exists
dockerfile="${package_name}.dockerfile"
if [ ! -f "$dockerfile" ]; then
echo "Warning: No dockerfile found for $json_file"
continue
fi
# Extract version from package.json
version=$(jq -r '.version' "$json_file")
# Build the image name
image_name="${{ secrets.DOCKERHUB_USERNAME }}/${package_name}"
echo "Checking if $image_name:$version exists..."
if check_tag_exists "$image_name" "$version"; then
echo "Version $version already exists for $image_name, skipping build"
continue
fi
echo "Building $image_name:$version"
# Build and push docker image
docker build \
-t "$image_name:$version" \
-f "$dockerfile" \
. \
--push
popd > /dev/null
3 changes: 3 additions & 0 deletions packages/fastsurfer.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM deepmi/fastsurfer:2.5.3

ENV PATH="/fastsurfer:$PATH"

0 comments on commit 9d9cef9

Please sign in to comment.