diff --git a/.github/workflows/build-using-cnb-buildpack.yml b/.github/workflows/build-using-cnb-buildpack.yml new file mode 100644 index 0000000..d6d617d --- /dev/null +++ b/.github/workflows/build-using-cnb-buildpack.yml @@ -0,0 +1,81 @@ +name: "Build using cnb buildpack" +permissions: + packages: write +on: + push: + branches: + - '*' + tags: + - "v?[0-9]+.[0-9]+.[0-9]+*" +env: + CNB_IMAGE_NAME: cnb-app + SERVICE_NAME: 'mysql' + SERVICE_IMAGE: "mariadb:11.2-jammy" + SERVICE_HEALTH_CMD: "/usr/local/bin/healthcheck.sh --connect --innodb_initialized" + SERVICE_PORT: 3306 + SERVICE_USERNAME: '22032e25-4aba-417f-a394-8bbd78d920cd' + SERVICE_PASSWORD: 'StbQ4EovUpwQjD0cT1Hr7PKBG' + SERVICE_HOST: "dynamically_generated" + DATABASE_NAME: my-mysql-db-sample + DEBUG: 0 + +jobs: + package-app: + name: "Package ${{ github.repository }} as CNB app" + runs-on: ubuntu-latest + + steps: + - + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + # Number of commits to fetch. 0 indicates all history for all branches and tags. + # Default: 1 + fetch-depth: 1 + - + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Setup pack for ${{ github.repository }} + uses: buildpacks/github-actions/setup-pack@v5.0.0 + - + name: Packaging app from ${{ github.repository }} pushed by ${{ github.actor }} + shell: bash + run: | + echo "Pack Build ${{env.CNB_IMAGE_NAME}} (${{github.repository}})" + pack build ${{env.CNB_IMAGE_NAME}} --path assets/sinatra_app + echo "Pack Inspect ${{env.CNB_IMAGE_NAME}} (${{github.repository}})" + pack inspect ${{env.CNB_IMAGE_NAME}} + - + name: Testing app + shell: bash + run: | + source ./setup-prerequisite.sh + ./run-tests.sh + - + name: Tag version ${{github.ref_name}} + if: github.ref_type == 'tag' + run: | + docker tag ${{env.CNB_IMAGE_NAME}}:latest ghcr.io/${{ github.repository }}:${{github.ref_name}} + - + name: Tag with common data + run: | + docker tag ${{env.CNB_IMAGE_NAME}}:latest ghcr.io/${{ github.repository }}:latest + docker tag ${{env.CNB_IMAGE_NAME}}:latest ghcr.io/${{ github.repository }}:${{github.sha}} + echo "cleanup built image" + docker image rm ${{env.CNB_IMAGE_NAME}}:latest + echo "dump existing images" + docker images + - + name: Publish ghcr.io/${{ github.repository }} + run: | + echo "publish all tags" + docker push --all-tags ghcr.io/${{ github.repository }} + + diff --git a/assets/sinatra_app/Gemfile b/assets/sinatra_app/Gemfile index f286c1d..6db19ab 100644 --- a/assets/sinatra_app/Gemfile +++ b/assets/sinatra_app/Gemfile @@ -6,4 +6,6 @@ gem 'sinatra' # gem 'thin' gem 'mysql2' gem 'rackup' -gem 'bigdecimal' #warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. Also contact author of mysql2-0.5.6 to add bigdecimal into its gemspec. +gem 'bigdecimal' # warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec. Also contact author of mysql2-0.5.6 to add bigdecimal into its gemspec. +gem 'logger', '~> 1.6', '>= 1.6.1' # warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0 +gem 'ostruct', '~> 0.6.0' # warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0 \ No newline at end of file diff --git a/assets/sinatra_app/Gemfile.lock b/assets/sinatra_app/Gemfile.lock index 9454074..bf2754b 100644 --- a/assets/sinatra_app/Gemfile.lock +++ b/assets/sinatra_app/Gemfile.lock @@ -3,9 +3,11 @@ GEM specs: base64 (0.2.0) bigdecimal (3.1.8) + logger (1.6.1) mustermann (3.0.3) ruby2_keywords (~> 0.0.1) mysql2 (0.5.6) + ostruct (0.6.0) rack (3.1.7) rack-protection (4.0.0) base64 (>= 0.1.0) @@ -30,7 +32,9 @@ PLATFORMS DEPENDENCIES bigdecimal + logger (~> 1.6, >= 1.6.1) mysql2 + ostruct (~> 0.6.0) rackup sinatra diff --git a/assets/sinatra_app/project.toml b/assets/sinatra_app/project.toml new file mode 100644 index 0000000..b0d2117 --- /dev/null +++ b/assets/sinatra_app/project.toml @@ -0,0 +1,11 @@ +[_] +schema-version = "0.2" +id = "com.orange-cloudfoundry.sample-apps.mysql" +name = "MySQL sample app" +#version = "1.0.0" + +[io.buildpacks] +builder = "paketobuildpacks/builder-jammy-full" +#include = [ +# "assets/sinatra_app" +#]