Sign inSign up

pdgsolutions/ionic

By pdgsolutions

•Updated about 7 years ago

Develop Ionic 3/4 applications without having to worry about the CLI dependencies.

Image
0

10K+

pdgsolutions/ionic repository overview

⁠Dockerized Ionic 3 Framework Development

Develop Ionic 3/4 applications without having to worry about the CLI dependencies.

⁠Starting a Project with this Framework

IMPORTANT: Docker for MacOSx doesn't support forwarding USB devices into the container so it's not possible to deploy the app from into the container to mobile devices. You'll find alternative commands for MacOSx systems.

⁠Using 'docker run'

To start a container:

$ docker run -it --rm \
  -p 8100:8100 \
  -p 35729:35729 \
  -v /path/to/your/ionic-project:/myApp:z \
   pdgsolutions/ionic3:1.0.5

To speed up things, let's create an alias:

-- First open your '.bashrc' file.

$ vim ~/.bashrc

-- Add the following at the bottom of the file and save it.

alias ionic="docker run -ti --rm -p 8100:8100 -p 35729:35729 --privileged -v /dev/bus/usb:/dev/bus/usb -v ~/.gradle:/root/.gradle -v \$PWD:/myApp:rw pdgsolutions/ionic3:1.0.5 ionic"

-- Source the file to reload changes

$ source ~/.bashrc

-- Finally use the alias to create new projects:

$ ionic start myApp tabs
$ cd myApp
$ ionic serve --external --address=0.0.0.0 --no-open

To preview your app while you code, visit any of the following links in your web browser:

http://localhost:8100
http://localhost:8100/ionic-lab
http://localhost:35729

Your docker host ip address can also be used in place of localhost

To use the alias to test your app on your android device, just make sure that debugging is enabled

$ cd myApp
$ ionic platform add android
$ ionic build android
$ ionic run android

⁠Using 'docker-compose.yml' file

Let’s start by making a local directory for gradle, so you don’t have to install it each time you run your ionic docker container

$ mkdir ~/.gradle

Create compose file in your project root

$ mkdir -p Projects/my-app
$ cd Projects/my-app
$ sudo vim docker-compose.yml

Add the following content to it:

version: '3'

services:

  my-app:
    image: pdgsolutions/ionic3:1.0.5
    container_name: my-app
    privileged: true
    volumes:
      - ./:/myApp:z
      - ~/.gradle:/root/.gradle
      - /dev/bus/usb:/dev/bus/usb
    tty: true
    stdin_open: true

Initialise a new ionic project in your Projects directory

$ docker-compose run --rm my-app ionic start my-app blank

Move the contents of the installation directory to the parent working directory and remove the folder now because it's empty

$ sudo mv my-app/{.,}* . && sudo rm -r my-app

Run the project in detached mode with the -d flag

$ docker-compose up -d

To preview your app while you code, visit any of the following links in your web browser:

http://localhost:8100
http://localhost:8100/ionic-lab
http://localhost:35729 <--------live-reload--------|

Your docker host ip address can also be used in place of localhost

Publish your App when done coding

$ docker-compose run my-app ionic build android --release

If you haven’t already done this, you’ll need to create a private key. You’ll only need to do this one time.

$ keytool -genkey -v \
  -keystore my-release-key.keystore \
  -alias alias_name \
  -keyalg RSA \
  -keysize 2048 \
  -validity 10000

Sign the apk with Jarsigner

$ docker run -ti --rm -v ~/.gradle:/root/.gradle -v \
  $PWD:/myApp:rw pdgsolutions/ionic3:1.0.5 jarsigner \
  -verbose -sigalg SHA1withRSA \
  -digestalg SHA1 \
  -keystore $APP_NAME.keystore ./platforms/android/build/outputs/apk/release/android-release-unsigned.apk $APP_NAME \
  -tsa http://timestamp.digicert.com

Now we need to run Zipalign

In this example we’re creating our release. In yours, you’ll replace the output at the end with the name of your own release.

$ docker run -ti --rm -v ~/.gradle:/root/.gradle -v \
  $PWD:/myApp:rw pdgsolutions/ionic3:1.0.5 \
  zipalign -v 4 \
  ./platforms/android/build/outputs/apk/release/android-release-unsigned.apk \
  ./platforms/android/build/outputs/apk/release/$APP_NAME-$APP_VERSION-release.apk

Now you can upload the APK to the Google Play store and start getting downloads.

Tag summary

Content type

Image

Digest

Size

803.1 MB

Last updated

about 7 years ago

docker pull pdgsolutions/ionic