Internet and communication technologies have lowered the costs to collaborate for communities, leading to new services like user-generated content and social computing and, through collaboration, collectively built infrastructures, such as community networks. Community networks are formed when individuals and local organisations from a geographic area team up to create and run a community-owned IP network to satisfy the community's demand for ICT. Internet access is often considered the main service of community networks, but the provision of services of local interest within the network is a unique opportunity for community networks, which is currently predominantly unexplored. The consolidation of today's cloud technologies offers community networks the possibility to collectively build community clouds, building upon user-provided networks, and extending towards an ecosystem of cloud services. We propose a framework for building a collaborative distributed community cloud system that employs resources contributed by the members of the community network for provisioning infrastructure and software services. This framework is tailored to the specific social, economic, and technical characteristics of community networks and requirements for community clouds in order to be successful and sustainable. We materialise this framework in the implementation of the Cloudy distribution. We conduct real deployments of these clouds in the Guifi.net community network and evaluate cloud-based applications such as service discovery and distributed storage. This deployment experience supports the feasibility of community clouds and our measurements demonstrate the performance of services and applications running in these community clouds. Our results encourage the development and operation of collaborative cloud-based services using the resources of a community network. We anticipate that such services can effectively complement commercial offers and have the potential to boost innovation in application areas in which end-user involvement is required.