We study the conditions for the emergence of cooperation in a spatial common-pool resource (CPR) game. We consider three types of agents: cooperators, defectors and enforcers. The role of enforcers is to punish defectors for overharvesting the resource. Agents are located on a circle and they only observe the actions of their two nearest neighbors. Their payoffs are determined by both local and global interactions and they modify their actions by imitating the strategy in their neighborhood with the highest average payoffs on average. Using theoretical and numerical analysis, we find a large diversity of equilibria to be the outcome of the game. In particular, we find conditions for the occurrence of equilibria in which the three strategies coexist. We also derive the stability of these equilibria. Finally, we show that introducing resource dynamics in the system favors the occurrence of cooperative equilibria.