A bubble initiated near a rigid boundary may be almost in contact with the boundary because of its expansion and migration to the boundary, where a thin layer of water forms between the bubble and the boundary thereafter. This phenomenon is modelled using the weakly compressible theory coupled with the boundary integral method. The wall effects are modelled using the imaging method. The numerical instabilities caused by the near contact of the bubble surface with the boundary are handled by removing a thin layer of water between them and joining the bubble surface with its image to the boundary. Our computations correlate well with experiments for both the first and second cycles of oscillation. The time history of the energy of a bubble system follows a step function, reducing rapidly and significantly because of emission of shock waves at inception of a bubble and at the end of collapse but remaining approximately constant for the rest of the time. The bubble starts being in near contact with the boundary during the first cycle of oscillation when the dimensionless stand-off distance γ = s/Rm < 1, where s is the distance of the initial bubble centre from the boundary and Rm is the maximum bubble radius. This leads to (i) the direct impact of a high-speed liquid jet on the boundary once it penetrates through the bubble, (ii) the direct contact of the bubble at high temperature and high pressure with the boundary, and (iii) the direct impingement of shock waves on the boundary once emitted. These phenomena have clear potential to damage the boundary, which are believed to be part of the mechanisms of cavitation damage.