An open API service indexing awesome lists of open source software.

https://github.com/hamdifourati/cordova-android-builder

Build Cordova Application for Android using Docker
https://github.com/hamdifourati/cordova-android-builder

cordova-android docker-image

Last synced: 5 months ago
JSON representation

Build Cordova Application for Android using Docker

Awesome Lists containing this project

README

          

# cordova-android-builder

## 🚀 Overview

`cordova-android-builder` is a lightweight Docker image designed to simplify the process of building Cordova Android applications. It provides a consistent and isolated environment with all the necessary tools (Node.js, npm, Cordova, Android SDK, Gradle) pre-configured, allowing you to build your Android APKs without worrying about local environment setups or conflicts.

This project is ideal for CI/CD pipelines, automated build systems, or local development where you need a clean, reproducible build environment for your Cordova Android projects.

## ✨ Features

* **Pre-configured Environment:** Includes Node.js, npm, Cordova CLI, Android SDK, and Gradle.

* **Consistent Builds:** Ensures your builds are reproducible across different machines.

* **Isolation:** Prevents conflicts with your local development environment.

* **Lightweight:** Optimized Docker image for faster pulls and smaller footprint.

* **CI/CD Friendly:** Easily integrates into your continuous integration and deployment workflows.

## 📦 Getting Started

These instructions will get you a copy of the project image up and running on your local machine.

### Prerequisites

You need to have Docker installed on your system.

* [Docker](https://docs.docker.com/get-started/)

### Usage

The `cordova-android-builder` image expects your Cordova project to be mounted into the container at `/app`. You can then execute Cordova commands from within this directory.

#### 1. Pull the Docker Image

First, pull the latest version of the image from Docker Hub:

```
docker pull hamdifourati/cordova-android-builder:latest
```

Or a specific version:
```
docker pull hamdifourati/cordova-android-builder:cordova-13 # Example version
```

#### 2. Build Your Cordova Android Project

Navigate to your Cordova project's root directory on your host machine. Then, run the Docker container, mounting your project and executing the build command:
```
docker run --rm -v "$(pwd):/app" hamdifourati/cordova-android-builder:latest /bin/bash -c "cd /app && cordova platform add android && cordova build android --release"
```

**Explanation of the command:**

* `docker run`: Executes a Docker container.

* `--rm`: Automatically removes the container when it exits.

* `-v "$(pwd):/app"`: Mounts your current host directory (where your Cordova project is) into the container's `/app` directory. This is crucial for the container to access your project files and for the build output (APK) to be saved back to your host.

* `hamdifourati/cordova-android-builder:latest`: Specifies the Docker image to use.

* `/bin/bash -c "..."`: Executes a shell command inside the container.

* `cd /app`: Changes the directory inside the container to your mounted project.

* `cordova platform add android`: Adds the Android platform to your Cordova project (if not already added).

* `cordova build android --release`: Builds the Android application in release mode. For debug builds, remove `--release`.

After the command completes, your generated APK file(s) will be available in your host machine's `platforms/android/app/build/outputs/apk/release/` (or `debug/`) directory within your Cordova project.

## 💡 Usage Examples

### Building a Debug APK
```
docker run --rm -v "$(pwd):/app" hamdifourati/cordova-android-builder:latest /bin/bash -c "cd /app && cordova platform add android && cordova build android"
```

### Running Cordova Commands

You can run any Cordova CLI command by replacing `cordova build android` with your desired command.

Example: Prepare the Android platform
```
docker run --rm -v "$(pwd):/app" hamdifourati/cordova-android-builder:latest /bin/bash -c "cd /app && cordova prepare android"
```
Example: List Cordova plugins
```
docker run --rm -v "$(pwd):/app" hamdifourati/cordova-android-builder:latest /bin/bash -c "cd /app && cordova plugin ls"
```

### Interactive Shell

If you want to explore the environment or debug, you can open an interactive shell inside the container:
```
docker run --rm -it -v "$(pwd):/app" hamdifourati/cordova-android-builder:latest /bin/bash
```

Once inside, you can navigate to `/app` and run Cordova commands directly. Type `exit` to leave the shell.

## 🐳 Docker Hub

The `cordova-android-builder` Docker image is publicly available on Docker Hub. You can find all available tags and versions there.

* [**View on Docker Hub**](https://hub.docker.com/r/hamdifourati/cordova-android-builder)

### Available Tags

We provide tags for different Cordova and Android SDK versions. It's recommended to use a specific version tag for production builds to ensure consistency.

* `latest`: Points to the most recent stable build.

* `android-35`: Corresponds to Cordova with Android 35.

* `cordova-13`: Corresponds to Cordova 13.

* ...and more. Check the [Docker Hub page](https://hub.docker.com/r/hamdifourati/cordova-android-builder/tags) for a complete list of tags.

To use a specific version, simply replace `latest` with the desired tag in your `docker pull` and `docker run` commands.

## 🤝 Contributing

Contributions are welcome! If you have suggestions for improvements, bug reports, or want to contribute code, please feel free to open an issue or submit a pull request on the [GitHub repository](https://github.com/hamdifourati/cordova-android-builder).

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ❓ Support / Contact

If you have any questions or need assistance, please open an issue on the [GitHub repository](https://www.google.com/search?q=https://github.com/hamdifourati/cordova-android-builder/issues).