Custom metabox for custom page template

<?
// Check:
// 1. If you are editing post, CPT, or page
// 2. If post type IS NOT SET
if( 'post.php' == basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']) && !isset($_GET['post_type']) ) {

    // get post ID
    $postid = $_GET['post']; 

    // check the template file name
    if ('my_template.php' == get_page_template_slug($postid) ) {
        // add your metabox here
        add_action( 'add_meta_boxes', 'my_metabox' );
    }

}

I don’t remember why I was checking post type, not post ID, but you can change

!isset($_GET['post_type'])

to check if post ID is set:

isset($_GET['post'])

Note: meta box will be available only after you save your post (page) using appropriate template.