docker-nativescript

a dockerized version of nativescript toolchain
git clone https://tongong.net/git/docker-nativescript.git
Log | Files | Refs | README | LICENSE

commit 9fcd0f9e105a9f6d37e6a46e2bff4f45ba2386c3
Author: tongong <tongong@gmx.net>
Date:   Fri, 25 Nov 2022 16:18:54 +0100

init

Diffstat:
ADockerfile | 46++++++++++++++++++++++++++++++++++++++++++++++
ALICENSE | 22++++++++++++++++++++++
AREADME.md | 42++++++++++++++++++++++++++++++++++++++++++
Abashrc.sh | 1+
4 files changed, 111 insertions(+), 0 deletions(-)

diff --git a/Dockerfile b/Dockerfile @@ -0,0 +1,46 @@ +FROM ubuntu:jammy + +# utilities +RUN apt-get update && \ + apt-get -y install apt-transport-https unzip curl usbutils --no-install-recommends && \ + rm -r /var/lib/apt/lists/* + +# java +RUN apt-get update && \ + apt-get -y install software-properties-common && \ + add-apt-repository ppa:openjdk-r/ppa && \ + apt-get -y install openjdk-17-jdk-headless && \ + rm -r /var/lib/apt/lists/* +ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk-amd64 + +# nodejs +RUN curl -sL https://deb.nodesource.com/setup_19.x | bash - && \ + apt-get update && \ + apt-get -y install nodejs --no-install-recommends && \ + rm -r /var/lib/apt/lists/* + +# nativescript +RUN npm install -g nativescript@8.3.3 && \ + ns error-reporting disable && \ + ns usage-reporting disable + +# android sdk +ENV ANDROID_HOME /opt/android-sdk +ENV PATH $PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/platform-tools +# link from https://developer.android.com/studio -> Command line tools only +ADD https://dl.google.com/android/repository/commandlinetools-linux-9123335_latest.zip /tmp/cmdtools.zip +RUN mkdir -p /opt/android-sdk/cmdline-tools && \ + unzip /tmp/cmdtools.zip && \ + rm /tmp/cmdtools.zip && \ + mv cmdline-tools/ /opt/android-sdk/cmdline-tools/tools +RUN echo "y" | sdkmanager "tools" "platform-tools" "platforms;android-32" \ + "build-tools;33.0.0" + +# gradle & example project +WORKDIR /tmp +RUN ns create example --js +WORKDIR /tmp/example +RUN ns build android +RUN rm -rf /tmp/example + +WORKDIR /app diff --git a/LICENSE b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright © 2022 + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the “Software”), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md @@ -0,0 +1,42 @@ +# docker-nativescript + +This projects aims to provide an up-to-date (November 2022) dockerized version +of NativeScript and its dependencies. + +- [NativeScript](https://www.nativescript.org/) (8.3.3) +- [Android SDK Tools](https://developer.android.com/) (33.0.0) +- [Android SDK Platform](https://developer.android.com/) (32) +- [Gradle](https://gradle.org/) (7.4) +- [NodeJS](https://nodejs.org/) (19.1.0) +- [Java](https://www.java.com/) (17.0.5) +- [Ubuntu](https://www.ubuntu.com/) (22.04) + +This project is based on: +- https://github.com/kristophjunge/docker-nativescript +- https://v7.docs.nativescript.org/angular/start/ns-setup-linux + +Testing was done exclusively with podman but it should work on docker as well. + +## usage +Build the image in the directory of the Dockerfile: +``` +podman build -t nativescript . +``` + +To conveniently use the container source the `bashrc.sc`. This introduces an +alias `dprefix` to run commands inside the container. For example: +``` +dprefix bash +dprefix ns create my-project +dprefix ns run android +``` + +## live development +The `--privileged` flag allows the container to access your USB devices. This +enables live development. Be sure to stop the `adb` server of your host machine +to make `adb` work inside the container. Then live development should work +with `dprefix ns run android`. + +## android emulator +This image does not include an emulator (and I do not know of a way to make the +Android emulator work inside a container). diff --git a/bashrc.sh b/bashrc.sh @@ -0,0 +1 @@ +alias dprefix="podman run -it --rm --privileged -u root -v /dev/bus/usb:/dev/bus/usb -v \$PWD:/app nativescript "