So this is a project that should help you produce Android project and build or/and xCode Project for iOS using docker file only, so it is basically a command lines that makes things easier for you to produce the final app build.
These files can be placed inside ionic project to use.
First you need to build and push builder image, it is separated to save time of rebuild that image everytime you need to build a new app, it is really waste of time if you build that image everytime. Use the following commands:
docker build . -f ./app-builder.Dockerfile -t app-builder
docker push app-builder
Optionally, you can use --build-arg
like
docker build . -f ./app-builder.Dockerfile \
--build-arg PACKAGE_MANAGER=yarn \
--build-arg ANDROID_PLATFORMS_VERSION=30 \
-t app-builder
Note: You can change app-builder with whatever name you like, but you need to change that as well inside Dockerfile
Docker builder Arguments:
GRADLE_VERSION
: gradle version you want to use. default is7.2
JAVA_VERSION
: java sdk version, default is8
ANDROID_PLATFORMS_VERSION
: android platform version that you want to target, default is 31ANDROID_BUILD_TOOLS_VERSION
: android build tools version that you want to target, default is 31.0.0PACKAGE_MANAGER
:npm
oryarn
default isnpm
NODE_VERSION
: Node JS that you desire to use, note that will be effecting npm version, default is16.8.0
that uses npm 7+YARN_VERSION
: If you use yarn, what is the yarn version default is1.22.10
USER
: That's helpful for permissions, default isionic
CORDOVA_VERSION
: Cordova cli you want to use default is10.0.0
IONIC_CLI_VERSION
: Ionic cli that you want to use, default is6.17.0
Then, you can use your image to build the app:
docker build . \
--build-arg ENV_NAME="${ENV_NAME}" \
--build-arg PACKAGE_ID="${PACKAGE_ID}" \
--build-arg PLATFORM=${platform} \
--build-arg VERSION="${version}" \
-f ./Dockerfile \
-t app-build
Arguments:
PACKAGE_ID
: is bundleId that you use for you appENV_NAME
: prod or dev, depends on what your files ionic project is called inside environments' folder.PLATFORM
:ios
orandroid
or both usingall
VERSION
: optional to override the version that specified insideconfig.xml
file, please refer toDockerfile
and uncomment the line that specify it.
Finally to get the build out of that image: For Android build:
docker run --user root:root --privileged=true -v ./build-output:/app/mount:Z --rm --entrypoint cp app-build -r ./output/android /app/mount
For iOS build (note you need to do pod install if you have firebasex):
docker run --user root:root --privileged=true -v ./build-output:/app/mount:Z --rm --entrypoint cp app-build -r ./output/ios /app/mount
cd ./build-output/ios && pod repo update && pod install
There is a build-app.sh file if you want to run all these steps using shell (you can comment first part from it later).
Good Luck 🧡