WooCommerce Images are uploading to the server but not attaching

I think that you have made a mistake in the last line. array_push is not doing what you are trying to achieve (check the Manual) same as update_post_meta accepts different arguments.

Besides that WooCommerce is storing galleries in simple comma separated list like 1,45,78,34 so you should change the last line
update_post_meta($post_id, array_push($post_id, '_product_image_gallery', $id));
to
update_post_meta($post_id, '_product_image_gallery', $id);
or if you add multiple images then instead of $id enter comma separated list.