Bitbucket self-hosted runner dind image cache

41 Views Asked by At

I can't cache my images on self-hosted runner.

I tried adding

caches:
      - docker

it doesnt seems to work. Still taking long time to build.

I want to cache following images:

  1. seriseyes/medsoft-deps:0.0.3-alpine in the Dockerfile
  2. alpine:latest in the bitbucket-pipeline.yaml
  3. docker:dind in the definitions.services

Here are my config files:

# Dockerfile for admin-service
FROM seriseyes/medsoft-deps:0.0.3-alpine

WORKDIR /app

COPY . .

RUN mkdir -p /root/.m2
COPY settings.xml /root/.m2/

RUN mvn clean install -DskipTests

ENTRYPOINT ["java", "-jar", "target/admin-api.jar"]

#bitbicket-pipelines.yaml
image: alpine:latest

definitions:
  services:
    docker:
      image: docker:dind
      memory: 3072

pipelines:
  custom:
    office-server:
      - step:
          fail-fast: true
          user: root
          runs-on:
            - self.hosted
            - linux
            - office
          name: Docker build & Push
          services:
            - docker
          script:
            - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin harbor.medsoft.care
            - TAG=$(echo $BITBUCKET_COMMIT | head -c 8) # Use the first 8 characters of the commit hash as the tag
            - DOCKER_BUILDKIT=1 docker build -t harbor.medsoft.care/medsoft8/admin-service:$TAG .
            - docker push harbor.medsoft.care/medsoft8/admin-service:$TAG
            - docker tag harbor.medsoft.care/medsoft8/admin-service:$TAG harbor.medsoft.care/medsoft8/admin-service:latest
            - docker push harbor.medsoft.care/medsoft8/admin-service:latest
      - step:
          fail-fast: true
          user: root
          runs-on:
            - self.hosted
            - linux
            - office
          name: Deploy to Kubernetes
          script:
            - TAG=$(echo $BITBUCKET_COMMIT | head -c 8) # Use the first 8 characters of the commit hash as the tag
            - pipe: atlassian/kubectl-run:3.10.0
              variables:
                KUBE_CONFIG: $KUBE_CONFIG
                KUBECTL_COMMAND: set image deployment/admin-service admin-service=harbor.medsoft.care/medsoft8/admin-service:$TAG

0

There are 0 best solutions below