The answer given by user60589 is correct but so compressed that it was downvoted; here is an expanded version.
Let $f:X\to\Bbb R$ be any continuous function. There is a homeomorphism $h:\Bbb R\to(0,1)$, and since $(0,1)\subseteq\Bbb R$, $h\circ f$ is a continuous function from $X$ to $\Bbb R$. Let $g=h\circ f$. By hypothesis $g[X]$ is closed in $\Bbb R$, and $g[X]$ is bounded (since it’s a subset of $(0,1)$), so $g[X]$ is compact. Finally, $h$ is a homeomorphism, so $h^{-1}$ is also a homeomorphism, and therefore
$$f[X]=h^{-1}\big[h\big[f[X]\big]\big]=h^{-1}\big[g[X]\big]$$
is also compact and hence bounded. Thus, every real-valued function on $X$ is bounded, and by this question (cited by user60589) $X$ is compact.