github.com/argoproj/argo-cd/v3@v3.2.1/hack/migrate-gitops-engine/update-dockerfile.sh (about)

     1  #!/bin/bash
     2  
     3  # Script to add two lines after the line containing "COPY go.* ./" in Dockerfile
     4  # The first line adds "green" and the second adds "red"
     5  
     6  DOCKERFILE="Dockerfile"
     7  
     8  # Check if Dockerfile exists
     9  if [[ ! -f "$DOCKERFILE" ]]; then
    10      echo "Error: $DOCKERFILE not found!"
    11      exit 1
    12  fi
    13  
    14  # Use sed to insert the two lines after the line containing "COPY go.* ./"
    15  # The pattern looks for the line containing "COPY go.* ./" and adds two lines after it
    16  sed -i.tmp '/COPY go\.\* \.\//{
    17  a\
    18  RUN mkdir -p gitops-engine
    19  a\
    20  COPY gitops-engine/go.* ./gitops-engine
    21  }' "$DOCKERFILE"
    22  
    23  # Remove the temporary file created by sed
    24  rm "${DOCKERFILE}.tmp" 2>/dev/null || true
    25  
    26  echo "Successfully added required lines to $DOCKERFILE:"
    27  echo ""
    28  echo "Lines around the modification:"
    29  grep -n -A 3 -B 1 "COPY go\.\* \./" "$DOCKERFILE"