As much as Thor: Ragnarok is a Thor movie, it's also crucial to setting the stage for Avengers: Infinity War. And nowhere is that more evident than in (spoiler alert!) the first Thor: Ragnarok post-credits scene, which ends the film on a pretty big cliffhanger, to say the least. The scene finds Thor and Loki safely reunited on the deck of the space ship used to evacuate Asgard, looking out over the cosmos. After their homeland was destroyed, Thor, as King, decided to take his people to Earth, the only other home he's ever known. Naturally, as seen earlier in the film with Doctor Strange's brief, but effective appearance, Loki isn't exactly welcome back on the planet he once tried to colonize.
"Do you really think it's a good idea to bring me back to Earth?" Loki asks Thor. "Probably not, to be honest," Thor responds. "But, I wouldn't worry, brother. I feel like everything's going to work out fine." Of couse, just as the words leave Thor's lips, the two are plunged into darkness by a giant shadow of what looks like an enormous space ship. Menacing and looming in front of them, the ship definitely does not give off a friendly, Guardians of the Galaxy vibe. If anything, it looks like Thor and Loki might be moments away from their first face to face with Thanos.
The ship doesn't look like anything the MCU has ever seen before, though it certainly is big enough to be Thanos' Sanctuary II ship, and the ship's intimidating introduction definitely means it can't be anything good. Assuming it is Thanos, it foreshadows what's to come in Avengers: Infinity War in some major ways. Fans already knew Thanos' search for the Infinity Stones would lead him to Earth, so his meeting Thor on the way seems to confirm that his intention to get to the human-populated planet. (It also sets the stage for his confrontation with the Avengers. As a majority of Avengers are Earth-bound heroes, this would be the most logical location for an initial fight.) However, it seems unlikely that Thanos would just happen to cross paths with Thor, unless something drew him directly into the ship's path — something like the Tesseract, an Infinity Stone.
During a sequence in the final battle of Thor: Ragnarok, it is heavily hinted that Loki steals the Tesseract (aka the Space Stone) from Asgard's vault. The Tesseract, fans might recall, is what Loki used in his attempt to take over the world in The Avengers, a film that coincidentally marked Thanos' first post-credits appearance in the MCU. It's possible that Thanos, who is hunting down the Stones, traced the Tesseract's power to Thor and Loki. That said, it's also possible that Loki still has a connection to Thanos, knew he was looking for the Tesseract, and decided to offer it to him.
However Thanos came to intercept Loki and Thor, based on the leaked trailer for Avengers: Infinity War, it seems likely that this scene will feed directly into the coming Avengers film. In the trailer, Thor literally crash landed onto the hood of the Guardians of the Galaxy's ship. Though he does not have an eye patch on in the trailer (as he does at the end of Ragnarok), his short hair suggests that the scene is, indeed, directly following Ragnarok. (As noted by Inverse, it's likely that Marvel didn't want to give away the ending to Ragnarok and will use special effects to put an eye patch on him in Infinity War.) Given the fact that he's flying through space, it seems safe to assume that by the time Thor meets the Guardians, he's been through some kind of inter-galactic scuffle.
Putting the Infinity War trailer and the Thor: Ragnarok post-credits scene together, it looks like whatever happens between Thor and Thanos ends with him hurtling through outer space. As for Loki, Hulk, and Valkyrie, who were on the same craft as Thor, their fate is less certain.