DevOps / Scripts yaml Advanced

GitLab CI Docker Build and Push

Build and push a Docker image to a registry on every merge to main.

yaml
stages: [build, push]
build:
  stage: build
  image: docker:24
  services: [docker:24-dind]
  script:
    - docker build -t registry/myapp:latest .
push:
  stage: push
  script:
    - docker push registry/myapp:latest

Prerequisites

  • GitLab CI
  • Docker registry

Pro Tips

  • → Use --cache-from to speed up builds.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
yaml
Level
Advanced
Read time
4 min
Published
Apr 2024
License
Commercial License

Newsletter

New modules every week, directly to your inbox.