The paper aims to generalize the classical derivation of the Korteweg-de Vries equation for small-amplitude long waves on the surface of a shallow layer of water (in the absence of viscosity and for irrotational flows), taking into regard the surface tension and possible non-uniformity of the bottom. The analysis gives rise to a coupled system of two equations for the velocity at the surface, $v(x,t)$, and local elevation of the surface, $\eta(x,t)$: $$\align
u_t +\eta_x +\varepsilon u_1u_x - \varepsilon \mu\eta_{xxxx}&=0,\\
\eta_x + u_x+\varepsilon[(\eta - b)]_x + (\varepsilon/3)u_{xxx}&=0,
\endalign$$ where $b(x)$ is the local depth, and small parameter $\varepsilon$ is the measure for the smallness of ratio of the local elevation of the free surface to the depth of the layer. It is proven that the full dynamics of the water waves is described by the above system for a long time interval. In fact, a priori estimates for the duration of the validity interval are essentially the same as obtained in earlier works, but estimates for the solution, and especially for its derivatives, are much stronger. The analysis is performed in the Eulerian (rather than Lagrangian) coordinates.