Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easy script for self building #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -46,6 +46,13 @@ keystore.properties
*.keystore
debug.keystore


# compile.sh
*.pfx
magen_keystore.pass
app-release.apk
image.tag

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
Expand Down
38 changes: 38 additions & 0 deletions Dockerfile
@@ -0,0 +1,38 @@
FROM ubuntu:18.04

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use alpine and apk?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this was prototyping to allow myself to compile the apk so I won't need to install from the google play and I could skip one trust hop.

I didn't put too much effort into improving this afterwards because I wasn't sure if you guys are even interested. if you are I can do that :)

Copy link

@Wassap124 Wassap124 Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not part of the team 🙌 so I can't really approve in their name.
Just wanted to start contributing by helping with open PRs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regardless, alpine is 10 times lighter than ubuntu which is pretty optimal for creating containers


RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
wget \
unzip \
openjdk-8-jdk && \
rm -rf /var/lib/apt/lists/*

RUN curl -sL https://deb.nodesource.com/setup_13.x | bash - && \
apt-get update && apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /magen/sdk
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip && \
unzip commandlinetools-linux-6200805_latest.zip && \
rm commandlinetools-linux-6200805_latest.zip

ENV ANDROID_SDK_ROOT="/magen/sdk"
ENV ANDROID_HOME="${ANDROID_SDK_ROOT}"
ENV PATH="${PATH}:${ANDROID_HOME}/emulator"
ENV PATH="${PATH}:${ANDROID_HOME}/tools"
ENV PATH="${PATH}:${ANDROID_HOME}/tools/bin"
ENV PATH="${PATH}:${ANDROID_HOME}/platform-tools"

RUN yes | $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses
RUN $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --update
RUN $ANDROID_HOME/tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "platform-tools" "platforms;android-28"

WORKDIR /magen

RUN git clone --depth 1 https://github.com/MohGovIL/hamagen-react-native.git
WORKDIR /magen/hamagen-react-native
RUN npm install
RUN cd android && ./gradlew | true 2>/dev/null

CMD /bin/bash
47 changes: 47 additions & 0 deletions compile.sh
@@ -0,0 +1,47 @@
#!/bin/bash
set -x
PASS_FILE="magen_keystore.pass"
KEYSTORE_FILE="magen.pfx"
IMAGE_TAG_FILE="image.tag"
ALIAS="magen"

GUES_PATH=/magen/hamagen-react-native

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does GUES stand for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo from GUEST :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notify me once you push and I'll resolve



if [ -f $IMAGE_TAG_FILE ]; then
IMAGETAG=$(cat $IMAGE_TAG_FILE);
else
IMAGETAG=$(head -c 12 /dev/urandom | sha256sum | head -c 12);
docker build . -t $IMAGETAG
echo $IMAGETAG > $IMAGE_TAG_FILE;
fi

# Check we have the password.
if [ -f $PASS_FILE ]; then
KEYSTORE_PASS=$(cat magen_keystore.pass);
else
KEYSTORE_PASS=$(head -c 32 /dev/urandom | sha256sum | head -c 64);
echo $KEYSTORE_PASS > $PASS_FILE;
fi

# Check we have the keystore.

if [ ! -f $KEYSTORE_FILE ]; then
keytool -genkey -alias $ALIAS -keystore $KEYSTORE_FILE -storetype PKCS12 -keyalg RSA -keysize 4096 -storepass $KEYSTORE_PASS -keypass $KEYSTORE_PASS -validity 10000 -dname CN=IL;
fi

HAMAGEN_KEY_PASSWORD=$HAMAGEN_STORE_PASSWORD

KEYSTORE_FILE="$GUES_PATH/$KEYSTORE_FILE"
docker run -v `pwd`:$GUES_PATH $IMAGETAG bash -c \
"cd ./android && \
HAMAGEN_KEYSTORE_PATH=$KEYSTORE_FILE \
HAMAGEN_KEY_PASSWORD=$KEYSTORE_PASS \
HAMAGEN_STORE_PASSWORD=$KEYSTORE_PASS \
HAMAGEN_KEY_ALIAS=$ALIAS \
HAMAGEN_DEBUG_KEYSTORE_PATH=dummy \
HAMAGEN_DEBUG_STORE_PASSWORD=dummy \
HAMAGEN_DEBUG_KEY_ALIAS=dummy \
HAMAGEN_DEBUG_KEY_PASSWORD=dummy \
./gradlew assembleRelease && \
cp ./app/build/outputs/apk/release/app-release.apk ../";