diff --git a/.gitignore b/.gitignore index b0f2efb..d6a3789 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .*.swp config/openedx/*.json config/nginx/*.conf +config/android/*.yaml mysql/config/database mysql/config/username mysql/config/password diff --git a/Makefile b/Makefile index f27926e..2c65570 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all configure build update migrate assets up daemon +.PHONY: all android configure build update migrate assets up daemon USERID ?= $$(id -u) EDX_PLATFORM_SETTINGS ?= universal.production @@ -67,6 +67,23 @@ cms-shell: $(DOCKER_COMPOSE_RUN_OPENEDX) cms ./manage.py cms shell +#################### Android app + +android: + docker-compose -f docker-compose-android.yml run --rm android + @echo "Your APK file is ready: ./data/android/edx-prod-debuggable-2.14.0.apk" + +android-release: + # Note that this requires that you edit ./config/android/gradle.properties + docker-compose -f docker-compose-android.yml run --rm android ./gradlew assembleProdRelease + +android-build: + docker build -t regis/openedx-android:latest android/ +android-push: + docker push regis/openedx-android:latest +android-dockerhub: android-build android-push + + #################### Deploying to docker hub build: diff --git a/README.md b/README.md index 77871b9..f6b782c 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,19 @@ Open a python shell in the lms or the cms: make cms-shell +## Android app (beta) + +The Android app for your platform can be easily built in just one command: + + make android + +If all goes well, the debuggable APK for your platform should then be available in ./data/android. To obtain a release APK, you will need to obtain credentials from the app store and add them to `config/android/gradle.properties`. The, run: + + make android-release + +Building the Android app for an Open edX platform is currently labeled as a **beta feature** because it was not fully tested yet. In particular, there is no easy mechanism for overriding the edX assets in the mobile app. This is still a work-in-progress. + + ## For developers In addition to running Open edX in production, you can use the docker containers for local development. This means you can hack on Open edX without setting up a Virtual Machine. Essentially, this replaces the devstack provided by edX. diff --git a/android/Dockerfile b/android/Dockerfile new file mode 100644 index 0000000..0e25ef0 --- /dev/null +++ b/android/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:16.04 + +RUN apt update && \ + apt upgrade -y && \ + apt install -y wget unzip git default-jre default-jdk + +RUN mkdir /openedx + +# Install Android SDK +# Inspired from https://github.com/LiveXP/docker-android-sdk/blob/master/Dockerfile +ENV ANDROID_SDK_VERSION 3859397 +ENV ANDROID_SDK_PATH /openedx/android-sdk +ENV ANDROID_HOME /openedx/android-sdk +RUN mkdir /openedx/android-sdk +WORKDIR /openedx/android-sdk +RUN wget https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \ + unzip sdk-tools-linux-${ANDROID_SDK_VERSION}.zip && \ + rm sdk-tools-linux-${ANDROID_SDK_VERSION}.zip + +# Install android app repo +RUN git clone https://github.com/edx/edx-app-android /openedx/edx-app-android +WORKDIR /openedx/edx-app-android + +# User-customized config +COPY ./edx.properties ./OpenEdXMobile/edx.properties +RUN mkdir /openedx/config +RUN ln -s /openedx/config/gradle.properties ./OpenEdXMobile/gradle.properties + +# Accept licenses +RUN yes | /openedx/android-sdk/tools/bin/sdkmanager --licenses + +CMD ./gradlew assembleProdDebuggable && \ + cp OpenEdXMobile/build/outputs/apk/*.apk /openedx/data/ diff --git a/android/edx.properties b/android/edx.properties new file mode 100644 index 0000000..f49574b --- /dev/null +++ b/android/edx.properties @@ -0,0 +1 @@ +edx.dir = '/openedx/config' diff --git a/config/android/edx.properties b/config/android/edx.properties new file mode 100644 index 0000000..e242f54 --- /dev/null +++ b/config/android/edx.properties @@ -0,0 +1,3 @@ +edx.android { + configFiles = ['universal.yaml'] +} diff --git a/config/android/gradle.properties b/config/android/gradle.properties new file mode 100644 index 0000000..28b46a6 --- /dev/null +++ b/config/android/gradle.properties @@ -0,0 +1,5 @@ +APPLICATION_ID=com.example.yourapp +RELEASE_STORE_FILE=/openedx/config/your.keystore +RELEASE_STORE_PASSWORD=your store password here +RELEASE_KEY_PASSWORD=your key password here +RELEASE_KEY_ALIAS=your key alias here diff --git a/config/android/templates/universal.yaml.templ b/config/android/templates/universal.yaml.templ new file mode 100644 index 0000000..3d41acf --- /dev/null +++ b/config/android/templates/universal.yaml.templ @@ -0,0 +1,5 @@ +API_HOST_URL: 'http://${LMS_HOST}' +ENVIRONMENT_DISPLAY_NAME: 'universal' +PLATFORM_NAME: '${PLATFORM_NAME}' +PLATFORM_DESTINATION_NAME: '${LMS_HOST}' +FEEDBACK_EMAIL_ADDRESS: 'support@${LMS_HOST}' diff --git a/configure b/configure index 1f64d38..0adedf6 100755 --- a/configure +++ b/configure @@ -189,6 +189,13 @@ def main(): delimiter='£', **configurator.as_dict() ) + # Android + substitute( + os.path.join('config', 'android', 'templates', 'universal.yaml.templ'), + os.path.join('config', 'android', 'universal.yaml'), + **configurator.as_dict() + ) + print("\nConfiguration files were successfuly generated. You may now run the app containers.") diff --git a/data/.gitignore b/data/.gitignore index 47563d2..74f2870 100644 --- a/data/.gitignore +++ b/data/.gitignore @@ -1,3 +1,4 @@ +android/ cms/ cms_worker/ lms/ diff --git a/docker-compose-android.yml b/docker-compose-android.yml new file mode 100644 index 0000000..6f64d75 --- /dev/null +++ b/docker-compose-android.yml @@ -0,0 +1,10 @@ +version: "3" +services: + + android: + image: regis/openedx-android:latest + build: + context: ./android + volumes: + - ./config/android/:/openedx/config/ + - ./data/android/:/openedx/data