-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Docker image * use latest version in Docker image * Dockerfile optimizations from PR feedback
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 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 @@ | ||
* |
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,25 @@ | ||
# Apktool in Docker | ||
We provide an easy way to leverage `apktool`, along with common Android tools such as `zipalign` and `apksigner`, all from within Docker. | ||
|
||
## Building the Docker image | ||
To build the image, use the included Dockerfile: | ||
```bash | ||
docker build -t apktool:latest . | ||
``` | ||
|
||
## Using the Docker image | ||
The best way to use the image is to create aliases to run the internal commands: | ||
```bash | ||
alias apktool="docker run --rm -ti --name=apktool -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest apktool" | ||
alias zipalign="docker run --rm -ti --name=zipalign -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest zipalign" | ||
alias apksigner="docker run --rm -ti --name=apksigner -v \"${PWD}:${PWD}\" -w \"${PWD}\" apktool:latest apksigner" | ||
``` | ||
|
||
## Running the commands | ||
You can then utilize these commands as you would if they were natively installed: | ||
```bash | ||
apktool d My.apk -o MyFolder | ||
apktool b MyFolder -o MyNew.apk | ||
zipalign -p -f 4 MyNew.apk MyNewAligned.apk | ||
apksigner sign --ks My.keystore MyNewAligned.apk | ||
``` |
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,42 @@ | ||
FROM openjdk:21-slim | ||
|
||
# Latest version as of 2023.10.01 | ||
# Ref: https://developer.android.com/studio/index.html#command-line-tools-only | ||
ARG COMMAND_LINE_TOOLS_VERSION=10406996 | ||
|
||
ARG ANDROID_SDK_ROOT=/opt/android-sdk | ||
|
||
RUN \ | ||
# Update | ||
apt-get update &&\ | ||
\ | ||
# Apktool | ||
apt-get install --no-install-recommends -y curl zipalign &&\ | ||
curl -o /usr/local/bin/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool &&\ | ||
curl -L -o /usr/local/bin/apktool.jar $(curl -s https://api.github.com/repos/iBotPeaches/Apktool/releases/latest |grep browser_download_url |awk '{print $2}' |sed 's/"//g') &&\ | ||
chmod +x /usr/local/bin/apktool /usr/local/bin/apktool.jar &&\ | ||
\ | ||
# Android SDK | ||
apt-get install -y --no-install-recommends \ | ||
git \ | ||
openssl \ | ||
wget \ | ||
unzip \ | ||
sdkmanager &&\ | ||
curl -o /tmp/tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${COMMAND_LINE_TOOLS_VERSION}_latest.zip &&\ | ||
mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools &&\ | ||
unzip -q /tmp/tools.zip -d ${ANDROID_SDK_ROOT}/cmdline-tools &&\ | ||
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/latest &&\ | ||
rm -v /tmp/tools.zip &&\ | ||
mkdir -p /root/.android/ && touch /root/.android/repositories.cfg &&\ | ||
yes | sdkmanager --licenses &&\ | ||
export BUILD_TOOLS_VERSION=$(sdkmanager --list |grep build-tools |grep -v rc |awk '{print $1}' |sed 's/build-tools;//g' |sort |tail -n1) &&\ | ||
sdkmanager --install "build-tools;${BUILD_TOOLS_VERSION}" &&\ | ||
ln -s ${ANDROID_SDK_ROOT}/build-tools/${BUILD_TOOLS_VERSION} /opt/bin &&\ | ||
\ | ||
# Cleanup | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
ENV PATH ${PATH}:/opt/bin | ||
|
||
CMD ["/usr/local/bin/apktool"] |
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