-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from kaitj/enh/docker
Add fastsurfer docker + workflow
- Loading branch information
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM deepmi/fastsurfer:2.5.3 | ||
|
||
ENV PATH="/fastsurfer:$PATH" |