In this paper, we focus on the reconfigurable intelligent surface (RIS) assisted single-cell uplink communication network scenario. In the network, one cellular link and multiple device-to-device (D2D) links sharing the same spectrum resources combine direct and reflective channel transmissions with the assistance of the RIS, which is adopted to alleviate the interference by fully using the beamforming capability. Subjected to qualityof-service (QoS) and total power constraints, a system sumrate maximization problem is formulated by jointly optimizing transmission powers of all links and discrete phase shifts of all RIS elements. Since it is a mixed integer non-convex non-linear problem, we decompose it into two sub-problems, and apply the alternating optimization to obtain a sub-optimal solution efficiently. For the power allocation sub-problem, it is a difference of concave functions (DC) problem, which is transformed to a convex one by the multivariate Taylor expansion and then solved with the gradient descent method. For the phase shift subproblem, a local search algorithm is utilized. Simulation results verify that our proposed scheme can eliminate the interference of D2D networks better than the scheme without RIS and other benchmark schemes.