# How to Move Apps into ACC?

If you've been developing a web application locally using the **Django** framework and are now ready to take it live, deploying it to **ACC** is a powerful next step. ACC provides a scalable, cloud-native environment designed for modern commerce applications, allowing you to host, build, and manage your apps with ease.

{% stepper %}
{% step %}
If your application is written in **Python** using the **Django** framework, your local project directory may look like this:

```
├── manage.py
├── quickstart
│   ├── __init__.py
│   ├── __pycache__
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── requirements.txt
```
{% endstep %}

{% step %}
After setting up and running the application locally, you should see the expected output in the browser.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FbvAuCXM0faVaI5CQx0Y7%2Fimage.png?alt=media&#x26;token=12d971f5-95a4-4c6f-aca3-d426a7b0a52a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
To run your application on **ACC**, you’ll need to add **three essential files** to your project directory:

* `akinon.json` – This JSON file contains the manifest-level information of your application.
* `Procfile` – Includes the necessary commands to run the application within ACC.
* `build.sh` – ACC stores image files for each new version of the application. This shell script file should contain the package contents of these image files and instructions on how they should be executed.

**Sample akinon.json:**

```

{
 "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": []
}
```
{% endstep %}

{% step %}
By including this file, specific requirements for ACC are defined regarding the Docker image of the application. This configuration guides versioning and the necessary commands during the build and release stages. It is important to note that the **akinon.json** file offers additional opportunities beyond these essentials. For more detailed information, refer to the [ACC App Manifest (akinon.json) and Procfile](how-to-configure-your-acc-application-with-akinon.json-and-procfile).
{% endstep %}

{% step %}
Next, the contents of the **build. sh** file will be explored:

```
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
```

{% hint style="info" %}
Including this file allows specification of the actions ACC must take with the version image whenever a new version is built.
{% endhint %}
{% endstep %}

{% step %}
Finally, the **Procfile** must be added.

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

Given that the **Gunicorn** library is being used to handle the **web** part of our application, it is crucial to specify the appropriate command in the Procfile using the standard format mentioned earlier.

The provided command is responsible for running our application and setting the format for access logs. If you wish to run your own application, ensure that you input the required command in the 'web: command' format.

{% hint style="info" %}
The `web:` prefix is required, and the app **must run on port 8008**, which is the only supported port in ACC.
{% endhint %}
{% endstep %}

{% step %}
Three essential files have been added to the application directory. As a result, the application directory should now resemble the following:

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

{% step %}
Your app is now ready to be deployed to ACC.
{% endstep %}
{% endstepper %}

## <mark style="color:red;">Creating a Public Key​</mark> <a href="#creating-a-public-key" id="creating-a-public-key"></a>

To enable ACC to create a repository for the application and allow for development submissions, users must register an SSH Public Key within the ACC. If a Public Key has been previously provided, this step can be skipped.&#x20;

{% stepper %}
{% step %}
To create an SSH Public Key, users can use the following command:

<pre><code><strong>ssh-keygen -t rsa -b 4096
</strong></code></pre>
{% endstep %}

{% step %}
This command has created a Private and a Public Key. The Public Key will be generated under the **.pub** extension. Next, copy this Public Key:

```
pbcopy < ~/.ssh/acc_rsa.pub
```
{% endstep %}

{% step %}
If `pbcopy` doesn’t work, open the file manually and copy its contents. Then paste it into ACC.

{% hint style="info" %}
For more info, see the [**Public Keys**](how-to-generate-and-add-public-keys-in-acc) documentation.
{% endhint %}
{% endstep %}
{% endstepper %}

## <mark style="color:red;">Creating an Application</mark>​ <a href="#creating-an-application" id="creating-an-application"></a>

Applications within the ACC are stored in **git** repositories. To publish each version, users must push the corresponding **tag** to the git repository in ACC.

If the application is not currently versioned with git, a git repository can be created within the application directory by running the following command through the terminal:

{% stepper %}
{% step %}
If you're not currently versioning the application with git, create a git repository within the application by running the following command in the application directory through the terminal:

```
git init
```
{% endstep %}

{% step %}
To link your git repository in the local environment to the one within ACC, first add a new _**remote**_ registry to your local git repository.

* **remote\_name**: For clarity, consider using a name that includes "acc" to distinguish it from your development repo.
* **remote\_address**: Copy and paste the URL that starts with "ssh://" of your application from the application list on the “My Applications” page in ACC into this field.

```
git remote add [remote_name] [remote_address]
```
{% endstep %}

{% step %}
Lastly, execute the following command:

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

{% step %}
To verify whether you have successfully added it, run this command:

```
git remote -v
```
{% endstep %}

{% step %}
The application can now be sent from the local environment to ACC. Create a new tag and push the first version.

```
git add .
git commit -m "Quickstart v1.0.0"
git tag v1.0.0
git push acc v1.0.0
```
{% endstep %}

{% step %}
After running the commands above, the v1.0.0 tag will be sent to the ACC repository.
{% endstep %}
{% endstepper %}

The next step is to initiate the version build corresponding to this tag.

## <mark style="color:red;">Building Versions</mark>​ <a href="#building-versions" id="building-versions"></a>

{% stepper %}
{% step %}
Go to the **“My Applications”** page in the ACC dashboard. Click on the name of your application. You’ll be directed to the application’s detail page, which includes a section for builds.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2FemiqJU0swcEZBisHuxiw%2Fimage2-43db9d30cd7a405880de0892703c972b.png?alt=media&#x26;token=7c599161-9df3-4ddf-bb2d-a74ec7b9f224" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Follow the instructions under the **“Building Application”** section of the  [My Application](how-to-create-manage-build-and-deploy-applications-in-acc) documentation to trigger the build process.
{% endstep %}

{% step %}
As your version is being built, you'll see one of the following statuses:

* **Initializing**: The build has started and is being prepared.
* **Completed**: The build finished successfully and is ready to deploy.
* **Failed**: The build encountered an error.

If the status shows **Failed**, click on the build to view the error logs and troubleshoot the issue.

Once the build is marked **Completed**, you're ready to move on to deployment.
{% endstep %}
{% endstepper %}

## <mark style="color:red;">Creating a Project</mark>​ <a href="#creating-a-project" id="creating-a-project"></a>

In ACC, applications are installed into **projects**, which allow you to run different versions of your app in different environments (e.g., staging, production).

* If you **already have a project**, you can skip this step.
* If not, follow the steps outlined in the **“Creating Project”** section of the [Project and Services](#creating-a-project) documentation.

## <mark style="color:red;">Installing the Application​</mark> <a href="#installing-the-application" id="installing-the-application"></a>

As there is currently no project linked to Omnitron, the next step is to install the application into a project. To do this, follow the steps outlined in the [App Store](how-to-install-applications-from-the-app-store-in-acc) documentation under “Adding an Application to a Project.”

## <mark style="color:red;">Deploying the Application to the Project​</mark> <a href="#deploying-the-application-to-the-project" id="deploying-the-application-to-the-project"></a>

{% stepper %}
{% step %}
Go back to **“My Applications”** and click on your application’s name. Scroll to the **Installed Projects** section to see which project the app is installed in.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F5Yh4QlAj6M4ayTfIOO0h%2Fimage3-d73d43ff789d2d42a10de5fb35895457.png?alt=media&#x26;token=c1e4ac7c-c28b-492a-90ce-6ddb079c1a2a" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Follow the steps under the **“Deploying Application”** section in the  [My Application](how-to-create-manage-build-and-deploy-applications-in-acc)  documentation. Once deployed successfully, the status will be updated to **Deployed**.
{% endstep %}

{% step %}
Navigate to the **Projects** page. Select your project and locate your application under the **Applications** section. Click on the application name to view its details. The application details page includes the **URL** where the app is running.

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2Fhi73WF6GS872c5cQudKb%2Fimage4-707f6db39d77b2bdf61f7537168a43da.png?alt=media&#x26;token=c0f77085-6f19-4b64-a1a0-bb76d0904870" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Click the URL to launch your app—now fully deployed and running in ACC!

<figure><img src="https://3333414532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIbwGN7KwvYi0iLbjtnXz%2Fuploads%2F0saYGwRD8LbnJW6CvkJJ%2Fimage.png?alt=media&#x26;token=2c706d8c-9584-4a4a-8bd5-a850407dd47f" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

Congratulations! Your application is now live on ACC. 🎉

The next step is to ensure your application has access to the necessary data. To configure database connectivity, continue with the  [Configure Database Connections](how-to-configure-database-connection-in-acc) guide.
