diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..9d738c747 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.git* +.dockerignore +Dockerfile +build +new-file-header.txt +CONTRIBUTORS.md +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..031d86252 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM debian:9 +# Docker build arguments +ARG SOURCE_DIR=/repo +ARG ARTIFACT_DIR=/dist +ARG ANDROID_DIR=/usr/lib/android-sdk +# Docker run environment +ENV SOURCE_DIR=/repo +ENV ARTIFACT_DIR=/dist +ENV ANDROID_DIR=/usr/lib/android-sdk + +# Prepare Debian build environment +RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list.d/backports.list \ + && apt-get update \ + && apt-get install -y mmv wget unzip git \ + && apt-get install -t stretch-backports -y npm android-sdk openjdk-8-jdk + +# Install Android repository tools +RUN rm -rf ${ANDROID_DIR}/tools \ + && wget http://dl-ssl.google.com/android/repository/tools_r25.2.3-linux.zip -O tools.zip \ + && unzip tools.zip -d ${ANDROID_DIR}/ \ + && rm -f tools.zip + +# Install SDK tools +# `yes` is required to accept licenses: +# https://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences/42125740#42125740 +# There will be a bit of delay (approx 30 seconds) +RUN yes | ${ANDROID_DIR}/tools/bin/sdkmanager "platform-tools" "platforms;android-27" "build-tools;27.0.3" "extras;android;m2repository" "extras;google;m2repository" + +RUN ln -sf ${SOURCE_DIR}/docker-build.sh /docker-build.sh + +# Prepare artifact volume +VOLUME ${ARTIFACT_DIR}/ + +# Copy repository +COPY . ${SOURCE_DIR}/ + +# Set docker-build entrypoint +ENTRYPOINT ["/docker-build.sh"] diff --git a/docker-build.sh b/docker-build.sh new file mode 100755 index 000000000..10755f6f8 --- /dev/null +++ b/docker-build.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Builds the APK inside the Docker container + +set -o errexit +set -o xtrace + +# Handle the release type +case ${RELEASE} in + 'production') + RELEASE_SUFFIX="" + NODE_ENV="production" + RFLAG="--release" + ;; + 'unminified') + RELEASE_SUFFIX="unminified_" + NODE_ENV="development" + RFLAG="--release" + ;; + 'debug') + RELEASE_SUFFIX="debug_" + NODE_ENV="development" + RFLAG="" + ;; +esac + +# Export environment variables +export ANDROID_HOME=${ANDROID_DIR} +export NODE_ENV + +# Move to source directory +pushd ${SOURCE_DIR} + +# Build APK +which gradle +gradle --version +gradle tasks +gradle assembleDebug + +# Move the artifacts out +mkdir -p ${ARTIFACT_DIR}/apk +mmv "${SOURCE_DIR}/platforms/android/build/outputs/apk/android-*.apk" "${ARTIFACT_DIR}/apk/jellyfin-android_${RELEASE_SUFFIX}#1.apk" diff --git a/new-file-header.txt b/new-file-header.txt new file mode 100644 index 000000000..a330192a5 --- /dev/null +++ b/new-file-header.txt @@ -0,0 +1,22 @@ +### This header should be used to start new files. +### It provides an explicit per-file license reference that should be present on all new files. +### To use this header, delete these lines and the following empty line, modify to +### the proper full path, and then add new code following the header and a single empty line. + +// +// Part of the Jellyfin project (https://jellyfin.media) +// +// All copyright belongs to the Jellyfin contributors; a full list can +// be found in the file CONTRIBUTORS.md +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see .