Skip to content

Containerize Application and Setup Container Registry Push Pipeline

Description

Set up Docker containerization for the microservice and create a GitLab CI/CD pipeline to build and push images to the GitLab Container Registry.

Technical Requirements

Dockerfile Setup

  • Use alpine:3.19
  • Optimize for smaller image size
  • Configure appropriate environment variables
  • Set up proper user permissions (non-root user)
  • Expose Port 8080
  • Make the entrypoint the executable generated by the build-microservice job in the .gitlab-ci.yml

GitLab CI/CD Pipeline

  • Configure GitLab Container Registry access
  • Set up CI/CD variables for registry authentication
  • Perform build and push in one job
  • Set the build-microservice job as a dependency
  • Implement proper versioning strategy based off $CI_COMMIT_SHA
  • Add container scanning