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

Add fastsurfer docker + workflow #203

Merged
merged 2 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not for this specific container, but if we have to build something larger its nice to have the larger 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"
Loading