Skip to content

Tutorial: Build your own package

This tutorial aims to guide you through the process of creating a package that can then be used to create a deployment.

Prerequisites

  1. You have to be a registered partner of Elastycloud.
  2. You need to have an account and be able to sign in to the Elastycloud Console.
  3. You need to have experience in developing for Magento 2.
  4. You must have the git and composer installed, and experience using them.
  5. You need a Bitbucket account, and permission to create new repositories.
  6. You need to get a personal Composer access key.

Tutorial

Before building the package, you have to select a name for it, and set the name in your elastycloud.yaml file.

  1. Sign in to the Elastycloud Console.
  2. Go to Packages in the menu.
  3. Press the + button (Add package) near the top right corner of the page.
  4. Fill in the form according to the Package details, using the Package key chosen earlier.
  5. Create a new Git repository in your Bitbucket account, following the Create Bitbucket repository instructions.
  6. Get the Elastycloud project skeleton, and push to your repository, following the Prepare and push repository instructions.
  7. Add and push a Git tag according to the Tag and trigger a build instructions.
  8. Go to the Package Versions page from the main menu and monitor the build status. Once it has been successfully built it can be deployed to production.

Additional information

Package details

A package can be seen as the connection between a deployment and the source-code in your repository.

Identifier Key
A globally unique key to identify your package. You reference this in your elastycloud.yaml.
Git repo name
The “full name” of your repository in bitbucket. You can find this in the URL of your repository. E.g. https://bitbucket.org/[Git repo name]/.
Preferred Stable Version
This is used to auto-select a version to install when none is specifically chosen. See: How to write version constraints.

Create Bitbucket repository

Sign in to Bitbucket and create a new repository.

Add a Bitbucket webhook in that repository (Bitbucket ‣ [repo] ‣ Settings ‣ Webhooks ‣ Add webhook) with the title "Elastycloud" and the URL https://webhook.elastycloud.io/git/bitbucket/magento. Check Enable request history collection and leave rest as default.

This will trigger a build on every push.

Note

Make sure that the Bitbucket user ElastycloudCICD has READ access to your repository.

Prepare and push repository

To get a template for your repository you can use our skeleton-repository:

Open a terminal to a local folder where you want to create the repository and run the following command:

git clone https://bitbucket.org/elastycloud/skeleton-magento.git
rm -rf skeleton-magento/.git

Replace package.key in skeleton-magento/elastycloud.yaml with your own package key.

Inside of the magento/ folder you will find composer.json, which contains a requirement for the meta-package elastycloud/package_magento-base. This is how all cloud related modules will be included in your project.

Set up a Git repository inside the folder that was created, add, and commit all files within, then push it to your own Bitbucket repository.

Repository structure

To initiate the project, run composer install in the Magento folder. This will fetch all the necessary Magento modules.

Once you have installed the project, the following files should be checked in to Git:

  • magento/app/etc/config.php
  • magento/composer.json
  • magento/composer.lock
  • elastycloud.yaml
  • .gitignore

All other files are optional.

Note

You configure how this project is built in elastycloud.yaml.

Tag and trigger a build

In order to trigger a build of your code, you must first tag it with a SemVer tag, e.g. 0.0.0-alpha.1, and then push that tag with Git.

git tag 0.0.0-alpha.1
git push --tags

Except for the build number, you can use all aspects of SemVer. This is because the builder automatically adds a build number.