tvo homework help login construction cv writing service open university creative writing ma review top creative writing undergraduate programs history of creative writing ppt are you going to do your homework creative writing majors in texas
Site Loader
docker

If you have wonder how you could off load building your App to another automated process outside your development machine, docker is a good tool to deploy your app.

Getting started

You have to install Docker first(https://docs.docker.com/install/) . After installing it to validate whether the installation is done properly, you can type docker command in your console.If you see that working, you’re ready to go.

android app with docker

Benefits:

Imagine you have a set of servers, and you have various item to build, you would prefer to have the servers the flexibility of building anything instead of being set to specific environment and build a single thing.

Docker provides such flexibility by setting the environment within the container, so that it could be deployed in any server to build a specific item. Different containers could be deployed on the same at different time to build its respective item.

Setting up the environment is much more easier, one just need to set to one image, and could be deployed to any server.

Build Android Image

1. Create a new directory. $mkdir exampleDocker

2. $cd exampleDocker. Create new file name: Dockerfile

3. $vi Dockerfile. Copy and paste below snippet

FROM gradle:4.10.0-jdk8

USER root ENV SDK_URL=”https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip” \ ANDROID_HOME=”/usr/local/android-sdk” \ ANDROID_VERSION=28 \ ANDROID_BUILD_TOOLS_VERSION=27.0.3

Download Android SDK

RUN mkdir “$ANDROID_HOME” .android \ && cd “$ANDROID_HOME” \ && curl -o sdk.zip $SDK_URL \ && unzip sdk.zip \ && rm sdk.zip \ && yes | $ANDROID_HOME/tools/bin/sdkmanager –licenses

Install Android Build Tool and Libraries

RUN $ANDROID_HOME/tools/bin/sdkmanager –update RUN $ANDROID_HOME/tools/bin/sdkmanager “build-tools;${ANDROID_BUILD_TOOLS_VERSION}” \ “platforms;android-${ANDROID_VERSION}” \ “platform-tools”

Install Build Essentials

RUN apt-get update && apt-get install build-essential -y && apt-get install file -y && apt-get install apt-utils –y

The command below is very important because it creates/builds a docker image to build Android projects:

$docker build -t android-build:android-gradle .

The command will download all the Android components to build an Android app. Push docker image to dockerHub

After building the Android docker image locally, We can push it to dockerhub and make it available for everyone. For Instance, you can follow the below steps to push your dockerImage to dockerHub.

Step 1: Create new Dockerhub repo.

1. Go to Dockerhub, loging and select Create -> Create Repository -> Create

2. Docker hub is repeating twice

Step 2: Push your docker image to dockerhub with the below command

1. Use same Dockerfile.

2. Build your docker image.

$ docker build -t android-build:android-gradle .

3. Run command “$docker images -a” and see your image was created

4. Add tag to image.

$ docker tag android-build:android-gradle andres2014/android-build:part1

5. Now the image has a tag, push it to hubdocker with below command:

$docker login (sign-out from organization)

$ docker push android2019/android-build:part1 Your image is available now to the world at hub.Docker.com. User can pull it like below:
$docker pull andres2014/android-build:part1

Docker Reference Link: * Get started with Docker (https://docs.docker.com/get-started/#recap-and-cheat-sheet) * Docker samples (https://docs.docker.com/samples/)

Useful Docker commands

Show all commands | $docker

Container list | $docker container ls

List images | $docker images

Remove image | $docker rmi MyImage

Containers process| $docker ps -a

Remove container | $docker rm -f process#

Remove stop | $docker stop process#

Stop all containers | $docker stop $(docker ps -a -q)

Delete all containers | $docker rm $(docker ps -a -q)

Post Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *