Skip to main content

How to Quickly Move Your Applications into Akinon Commerce Cloud

By following the directions below, you can easily move your applications that work successfully in a local environment to Akinon Commerce Cloud (ACC).

Let's assume that the application is written in the Python programming language and is built with the Django framework.

The fundamental file structure of a Django project looks like this:

├── manage.py
├── quickstart
│   ├── __init__.py
│   ├── __pycache__
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── requirements.txt

When we setup and run this app in a local environment, we see this screen:

Everything seems alright! Let's now start running this application within the ACC platform.

Firstly, there are three files we need to add to our application:

  • akinon.json is a json file comprising the manifest-level information of your application.
  • Procfile includes the commands required to enter the run the application within ACC.
  • build.sh: ACC keeps image files of each new version you wish to build to your application. The package contents of these image files and information on how they should be run need to be entered into this shell script file.

Here's how an akinon.json file should basically look like:

{
"name": "Quickstart Project",
"description": "Quickstart Project",
"scripts": {
"release": "",
"build": "sh build.sh"
},
"env": {},
"formation": {
"web": {
"min": 1,
"max": "auto"
}
},
"runtime": "python:3.8-alpine",
"addons": []
}

By adding this file, we have specified, for the ACC, the requirements regarding the docker image of our application that will be based while versioning, and which commands need to run in moments of build and release. Of course, the opportunities provided by akinon.json are not limited to these. You can check the related documents for detailed information

Next is the build.sh file:

set -euo pipefail

apk add python3-dev g++ jpeg-dev zlib-dev libffi-dev --no-cache
pip install -U --force-reinstall pip
pip install -r requirements.txt

apk del g++ python3-dev

By adding this file, we specify the required actions that need to be taken by the ACC on the version image every time we build a version.

Finally, let's add the Procfile:

web: gunicorn quickstart.wsgi -w 4 -b 0.0.0.0:8008 --access-logfile -

Since we're running the web leg of our application with the gunicorn library, we need to specify the related command within the Procfile in the standard as shown above.

The command above runs our application and dictates the writing format of access logs. In order to run your own application, you need to enter the required command in the 'web: command' format.

Note

You need to run your web applications via the 8008 port. The ACC can run web applications only through this port.

We have added three essential files to our application directory. Now, our application directory should look like this:

├── Procfile
├── akinon.json
├── build.sh
├── manage.py
├── quickstart
│   ├── __init__.py
│   ├── __pycache__
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── requirements.txt

Your application looks ready to be moved to the ACC. Let's move on to the next step.

Creating a Public Key

You need to enter an SSH Public Key registry within the ACC in order for ACC to create a repo for your application and for you to send your developments to this repo. You can skip this step if you have previously entered a Public Key.

If you're creating an SSH Public Key, you can easily do so with the command below:

ssh-keygen -t rsa -b 4096

This command has create a Private and a Public Key for us. The Public Key will be generated under the .pub extension. Let's copy this Public Key:

pbcopy < ~/.ssh/acc_rsa.pub

If 'pbcopy'is not working, you can open the key with any text editor program and copy the contents.

Let's add the Public Key we have copied to the ACC platform:

After adding the Public Key, we can now start creating our application within ACC.

Creating an Application

From the "My Applications" page, click the "New Application" button.

Fill in the relevant fields and continue:

And our application has been created for the ACC platform!

Within the ACC, applications are kept in git repositories. For every version you wish to publish, you need to push the tag of the related version to the git repository within ACC.

If you're not versioning your application with git you can create a git repo within your application by running the command below within your application directory on terminal:

git init

In order to link your git repo in the local environment to the git repo within ACC, you need to enter a new remote registry to your local git repo.

git remote add [remote_ismi] [remote_address]

remote_name: It'd be better to enter a name that includes "acc" in order not to mistake it for your development repo.

remote_address: You need to copy and paste the address that begins with "ssh://" in the URL field on My Applications page.

Finally, we will run this command:

git remote add acc ssh://abcdefgh@git-codecommit.eu-central-1.amazonaws.com/v1/repos/abcdefghe-abcdefhgh

To test whether you have successfully added it, you can run this command:

git remote -v

Now, we can send our application from the local to the ACC. Let's create a new tag and push our first version.

git add .
git commit -m "Quickstart v1.0.0"
git tag v1.0.0
git push acc v1.0.0

After running the commands above, the v1.0.0 tag will be sent to the ACC repo.

Next step is to receive a version build that belongs to this tag.

Building Versions

Let's click the name of our application on My Application page. The displayed screen will look like this:

On the screen that is displayed after clicking the Build button, we need to enter the version tag and related notes to click Build:

And our version is being built!

There are three build statuses: Initializing, Completed, and Failed. When the status transitions to Completed, it means we can deploy this version. If the status transitions to Failed, you can view the relevant build's error logs by clicking the button on the right.

Our version seems to have been successfully built!

Let's start deploying this version!

Creating a Project

We haven't yet created a project. Within ACC, applications can be installed within multiple projects. Thus, we can simultaneously publish different versions of the same application for different purposes.

Click the "New Project" button on the Projects page to create a new project.

We've created a project!

On the screen, you can see two sections as Services and Applications. Within the ACC environment, Services represent Akinon's services such as Omnitron, Live Commerce, Instore which can be used in your projects. When you create a project, Omnitron and Omnitron Frontend services are automatically installed within the project. As seen on the screen, Omnitron is Initializing Setup.

Installing the Application

Since we haven't yet developed a project linked to Omnitron at this point, we need to click the "New Application" button to add our application to this project.

Let's click our application and click the Install button on the screen.

After clicking the button, our project will start installation:

The Setup Status field displays Deploy Needed because we still haven't deployed our application to our project. We only installed it within this project.

Deploying the Application to the Project

We have arrived at the most thrilling phase :)

Let's revisit the My Applications page and click the name of our application.

Now, we can see that our application is installed to the Quickstart Project.

Let's select the checkbox next to the name of our project in order to deploy the version we have built in the previous steps to this project. And click the Deploy Selected Projects button.

On the next screen, we need to enter the version we wish to deploy and click the Deploy button.

And our deployment has started!

Our deployment is complete.

Let's enter our project to see our application and click our application in the Applications section.

Application detail includes the URL through which the application is run.

Let's click the URL to see our application run within ACC!

In this article, we followed the steps to run a basic web application within the ACC environment.

Next, we will discuss how we can fulfill the database needs of our application.