-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.bash_history | ||
.node-gyp | ||
.npm | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,20 @@ | ||
# Android development environment for ubuntu trusty (14.04). | ||
# version 0.0.1 | ||
# Cordova tools for ubuntu precise (12.04 LTS). | ||
# # version 0.0.1 | ||
FROM ahazem/android:v0.7.6 | ||
|
||
FROM ubuntu:14.04 | ||
MAINTAINER peernohell <[email protected]> | ||
|
||
MAINTAINER oren | ||
|
||
# Never ask for confirmations | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# RUN apt-get -y install python-software-properties git | ||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
software-properties-common \ | ||
git \ | ||
bzip2 \ | ||
wget \ | ||
ant \ | ||
openjdk-7-jre \ | ||
openjdk-7-jdk \ | ||
lib32z1 \ | ||
lib32z1-dev \ | ||
lib32stdc++6 \ | ||
--no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# lib32z1 lib32z1-dev lib32stdc++6 are needed to be able to run adb | ||
# software-properties-common Needed to be able to run add-apt-repository | ||
|
||
# Make sure the package repository is up to date | ||
# RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list | ||
# RUN apt-get update -qq && apt-get clean | ||
|
||
# RUN apt-get install -y bzip2 wget && apt-get clean | ||
|
||
# Install android sdk | ||
RUN wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz && \ | ||
tar -xvzf android-sdk_r23.0.2-linux.tgz && \ | ||
mv android-sdk-linux /usr/local/android-sdk && \ | ||
rm android-sdk_r23.0.2-linux.tgz | ||
|
||
# Add android tools and platform tools to PATH | ||
ENV ANDROID_HOME /usr/local/android-sdk | ||
ENV PATH $PATH:$ANDROID_HOME/tools | ||
ENV PATH $PATH:$ANDROID_HOME/platform-tools | ||
|
||
# Install latest android (19 / 4.4.2) tools and system image. | ||
RUN echo "y" | android update sdk --no-ui --force --filter platform-tools,android-19,build-tools-20.0.0 | ||
|
||
# Install nodejs | ||
RUN add-apt-repository -y ppa:chris-lea/node.js && \ | ||
apt-get update -qq && \ | ||
apt-get install -y nodejs | ||
# add nodejs to install cordova (code from https://index.docker.io/u/dockerfile/nodejs/) | ||
RUN add-apt-repository -y ppa:chris-lea/node.js | ||
RUN apt-get update | ||
RUN apt-get install -y nodejs | ||
|
||
# Append to $PATH variable. | ||
RUN echo '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bash_profile | ||
|
||
# install cordova | ||
RUN npm install -g cordova | ||
|
||
# Clean | ||
RUN apt-get autoremove && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.npm /var/cache/apt/* && \ | ||
npm cache clear | ||
# # install cordova | ||
RUN npm install -g cordova | ||
|
||
VOLUME /workspace | ||
WORKDIR /workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,46 @@ | ||
# Docker container for cordova development | ||
# Docker container for Cordova development | ||
|
||
## setup | ||
docker build -t cordova . | ||
* [Setup](#setup) | ||
* [New Project](#new-project) | ||
* [Miscellaneous](#Miscellaneous) | ||
|
||
# special permission for usb | ||
# mount usb volume | ||
# mount current folder | ||
docker run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb -v $(pwd):/app -p 3000:3000 cordova /bin/bash | ||
## Setup | ||
|
||
## push to public docker registry | ||
git clone [email protected]:oren/docker-cordova.git | ||
cd docker-cordova | ||
docker build -t cordova . | ||
echo "alias cdv='docker run --rm -i -v `pwd`:/workspace -w /workspace --privileged -v /dev/bus/usb:/dev/bus/usb cordova'" >> ~/.bash_aliases | ||
open new terminal | ||
|
||
docker tag cordova oreng/cordova:1.0.0 | ||
docker push oreng/cordova:1.0.0 | ||
The last command lets you use `cdv` for running any command inside the cordova container. | ||
|
||
## problems and solutions | ||
## New Project | ||
|
||
**DNS issue** | ||
cdv cordova create hello com.example.hello HelloWorld | ||
cd hello | ||
cdv cordova platform add android | ||
cdv cordova build | ||
connect your android with usb | ||
cdv adb devices # List usb devices. make sure you see your phone. | ||
cdv cordova run android | ||
|
||
uncomment `DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"` in /etc/default/docker and sudo service docker restart | ||
## Miscellaneous | ||
|
||
**Android build failing with build.xml:479: SDK does not have any Build Tools installed** | ||
I keep all my dockerfiles in a folder: | ||
|
||
android update sdk -u | ||
dockerfiles/ | ||
├── cordova | ||
│ ├── Dockerfile | ||
│ └── readme | ||
├── go | ||
│ ├── Dockerfile | ||
│ └── readme | ||
├── nginx | ||
│ ├── Dockerfile | ||
│ └── readme | ||
├── node | ||
├── Dockerfile | ||
└── readme | ||
|
||
**Unable to run 'adb': Cannot run program "/usr/local/android-sdk/platform-tools/adb": error=2, No such file or directory** | ||
The readme has the build command. For emample - `docker build -t cordova .`. I just run it once and add an alias to my .bash_profile | ||
|
||
sudo apt-get install lib32z1 lib32z1-dev | ||
sudo apt-get install lib32stdc++6 | ||
|
||
**cordova build => [Error: Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.]** | ||
|
||
? | ||
|
||
## start a cordova project | ||
|
||
cordova create Hello com.example.hello "Hello" | ||
cd Hello | ||
cordova platform add android | ||
cordova build | ||
cordova run android # to run on real device (connnected with usb) | ||
|
||
## misc commands | ||
|
||
alias cdv='docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb -v $(pwd):/app -p 3000:3000 cordova' | ||
cdv adb devices # List usb devices | ||
cdv cordova build android # Build app | ||
cdv cordova run android # Run app on device | ||
cdv npm update # Update my app dependecies | ||
|
||
## Resources | ||
|
||
* http://stackoverflow.com/questions/25210604/setting-up-a-development-environment-with-docker | ||
* https://github.com/nicopace/ionic-cordova-android-vagrant-docker/blob/master/Dockerfile#L50 |