1

I have a Spring Boot Kotlin Gradle project, and I'm trying to run a pipeline to build my project using docker-compose to run my CI tests, but I'm not able because docker-compose does not exists

So, following several posts on internet, I created a dependencies.sh file to run before gradle, that will install docker-compose for my tests, but I'm getting the error

./dependencies.sh: 6: ./dependencies.sh: apk: not found

I wrote another question about bitbucket pipelines using testcontainers, but so far no one could help me, so I changed the aproach

Embedded container tests Spring Boot fail on bitbucket pipeline

Can someone help me create a bitbucket-pipelines.yml with docker-compose for my tests, so far what I got is:

bitbucket-pipelines.yml file

image: openjdk:11

definitions:
  caches:
    gradleall: ~/.gradle
  services:
    docker:
      memory: 2048
  steps:
    - step: &Build
        name: Build and Test
        artifacts:
          - build/libs/**
          - build/reports/**
        script:
          - chmod +x dependencies.sh
          - ./dependencies.sh
          - bash ./gradlew clean build --stacktrace
        services:
          - docker

pipelines:
  default:
    - step: *Build

and dependencies.sh file

#!/usr/bin/env sh

set -eu

# Add python pip and bash
apk add --no-cache py-pip bash

# Install docker-compose via pip
pip install --no-cache-dir docker-compose
docker-compose -v

The error is

enter image description here

Javarian
  • 127
  • 2
  • 13

2 Answers2

0

It seems like the main OpenJDK Docker images are based on Debian, which uses apt-get instead of apk.

You could start by trying image: openjdk:11-alpine instead of image: openjdk:11; this should allow your current install process to work, but given the following caveat on the Docker page, I am thinking that it may be best to use their Debian images instead of their Alpine ones:

The OpenJDK port for Alpine is not in a supported release by OpenJDK, since it is not in the mainline code base.

I'm no expert on OpenJDK, though.

Alex Watt
  • 927
  • 5
  • 14
  • Thanks for the help, I made some progress by changing from openjdk to corretto, but I still couldn't make it work – Javarian Nov 16 '20 at 10:27
0

I made it work

I don't know if it's the best way, but my files ended up like this:

bitbucket-pipelines.yml

image: amazoncorretto:11-alpine-full

definitions:
  caches:
    gradleall: ~/.gradle
  services:
    docker:
      memory: 2048
  steps:
    - step: &Build
        name: Build and Test
        artifacts:
          - build/libs/**
          - build/reports/**
        script:
          - chmod +x dependencies.sh
          - ./dependencies.sh
          - sh ./gradlew clean build --stacktrace
        services:
          - docker

pipelines:
  default:
    - step: *Build

dependencies.sh

#!/usr/bin/env sh

set -eu

# Add python pip and bash
apk add --no-cache docker-compose

docker-compose -v
Javarian
  • 127
  • 2
  • 13
  • Glad to see you got it! The best I could do from the error was suggest using an Alpine-based image. – Alex Watt Nov 16 '20 at 14:37
  • Thx Alex, you gave me the direction – Javarian Nov 17 '20 at 18:08
  • I was facing a similar problem here. The output of Bitbucket Pipelines was `pipeline.sh not found`. I was using an image: node:alpine. After change to image:node:18.3.0 it works like a charm! Thx – Agostinho Neto Jan 24 '23 at 13:20