Taskfile.yaml 1.35 KB
Newer Older
Christoph Weyer's avatar
Christoph Weyer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
---
# https://taskfile.dev

version: '3'

dotenv:
  - .env

tasks:

  lint:
    desc: Lint the Dockerfile
    cmds:
      - hadolint Dockerfile

  build:
    deps: [lint]
    desc: Build the Docker image
    cmds:
20 21 22 23 24 25 26 27 28 29
      - docker build
               -t "${IMAGE_NAME}:latest"
               -t "${IMAGE_NAME}:${VERSION}"
               .

  test:
    deps: [build]
    desc: Show version of installed tool inside Docker container
    cmds:
      - docker run --rm "${IMAGE_NAME}"
Christoph Weyer's avatar
Christoph Weyer committed
30 31 32 33 34

  run:
    deps: [build]
    desc: Run ansible-lint inside Docker container
    cmds:
35 36 37 38
      - docker run --rm
                   -v "$(pwd)/testing:${DOCKER_WORKDIR}"
                   "${IMAGE_NAME}"
                   .
Christoph Weyer's avatar
Christoph Weyer committed
39 40 41 42 43

  bash:
    deps: [build]
    desc: Run bash inside Docker container
    cmds:
44 45 46 47
      - docker run --rm -it
                   -v "$(pwd)/testing:${DOCKER_WORKDIR}"
                   "${IMAGE_NAME}"
                   bash
Christoph Weyer's avatar
Christoph Weyer committed
48 49 50 51 52

  tag:
    deps: [lint]
    desc: Tag new version of Docker container
    cmds:
53 54
      - git tag "${VERSION}"
      - git push origin "${VERSION}"
Christoph Weyer's avatar
Christoph Weyer committed
55 56 57 58 59 60 61 62 63 64 65

  clean:
    desc: Delete Docker images and containers
    cmds:
      - docker container rm "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${VERSION}"
      - docker container prune -f
      - docker image rm "${IMAGE_NAME}:latest" "${IMAGE_NAME}:${VERSION}"
      - docker image prune -f
    ignore_error: true

...