Coder Social home page Coder Social logo

docker-nativescript's Introduction

Docker NativeScript

DockerHub Pulls DockerHub Stars GitHub Stars GitHub Forks GitHub License

NativeScript MediaWiki

Dockerized NativeScript and Android SDK.

Can be used for build automation and to run a docker based development environment. Based on the official Ubuntu image.

Usage

Development

The --privileged flag will make the USB devices of your host available to the container. That way you can run your NativeScript app on a real Android device from a docker container. Please note that you need to have USB debugging enabled. The usage of an emulator is currently not possible.

Change my-app to your app folder location. Connect an Android device and use the following command to create and run a new NativeScript application:

docker run -it --rm --privilged \
-v /my-app/:/app \
kristophjunge/nativescript \
bash -c "tns create my-app && mv ./my-app/* ./ && rm -r ./my-app && tns platform add android && tns run android"

Note that tns create will create a subdirectory for the application. In the example above the app folder contents will be moved up.

Development with Live Sync

You can have your changes live synchronized on your device while you are developing.

Connect an Android device and run the command:

docker run -it --rm --privileged \
-v /my-app:/app \
kristophjunge/nativescript \
tns livesync android --watch

To setup your development environment with docker-compose you can use the following snippet in a docker-compose.yml file:

version: '2'
services:
  app:
    image: kristophjunge/nativescript
    privileged: true
    volumes:
      - "./:/app"
    command: tns livesync android --watch

Build Automation

You don't need a connected Android device or running emulator to build an APK. You can build an APK with only NativeScript and the Android SDK or with this docker image.

Please note that you need a release key to build a signed Android APK package with NativeScript. Look here to find out how to generate a key. Read the NativeScript documentation to learn more about building for Android.

Mount your NativeScript application root directory, the directory where the final APK should be deployed and your release key.

Execute the build:

docker run --rm -it \
-v /my-app:/app \
-v /my-target-folder:/dist \
-v /my-release-key.jks:/key.jks \
kristophjunge/nativescript \
tns build android --release \
--key-store-path /key.jks \
--key-store-password SECRET_KEY_STORE_PASSWORD \
--key-store-alias KEY_ALIAS \
--key-store-alias-password SECRET_KEY_ALIAS_PASSWORD \
--copy-to /dist/release.apk

Replace SECRET_KEY_STORE_PASSWORD,KEY_ALIAS and SECRET_KEY_ALIAS_PASSWORD with the values of your release key.

To suppress the usage statistics dialog of the tns command you can prefix the command with the answer like that:

echo "n" | tns build android # ...

License

This project is licensed under the MIT license by Kristoph Junge.

Known issues

  • You currently can not run your app in an Android emulator. You can only use a real device for testing with this docker image. However building for Android does't require a device or emulator.

docker-nativescript's People

Contributors

wirus15 avatar

Watchers

 avatar

Forkers

frudas24

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.