Compare commits
No commits in common. "78f44e2aed072b9655841847b9b2de505536d797" and "62564e43f929dd9d1698b08d811caad94299a8a3" have entirely different histories.
78f44e2aed
...
62564e43f9
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,6 +1,9 @@
|
||||
AndroidSDK
|
||||
AndroidUser
|
||||
GradleUser
|
||||
*/node_modules
|
||||
*/build
|
||||
repos
|
||||
flutter
|
||||
cache
|
||||
projects/**
|
||||
+projects/.keep
|
||||
|
34
Dockerfile
34
Dockerfile
@ -121,30 +121,30 @@ RUN apt-get update \
|
||||
cmake \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
libgtk-3-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
# Install Chrome (flutter)
|
||||
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
||||
RUN apt install -y ./google-chrome-stable_current_amd64.deb
|
||||
|
||||
RUN mkdir -p /opt/android-studio ; wget -O - https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2024.1.1.11/android-studio-2024.1.1.11-linux.tar.gz | tar -xvz -C /opt
|
||||
|
||||
# Install VNC (remote gui editing)
|
||||
#
|
||||
ENV DISPLAY :20
|
||||
# Port is 5900+${DISPLAY}
|
||||
#
|
||||
EXPOSE 5920
|
||||
# Install build-essential, which includes g++ (required)
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
tightvncserver fluxbox
|
||||
build-essential \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
# Helper utilities...
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
qemu-system-x86 \
|
||||
libpulse-dev
|
||||
nano \
|
||||
openssh-client \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
# Needed for running android emulator
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
xterm \
|
||||
libpulse-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
COPY /scripts /scripts
|
||||
|
||||
|
0
GradleUser/.keep
Normal file
0
GradleUser/.keep
Normal file
203
LICENSE
Normal file
203
LICENSE
Normal file
@ -0,0 +1,203 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Files: license_accepter.sh - Copyright 2016-2024 Jing Li from https://github.com/thyrlian/AndroidSDK
|
||||
Files: * - Copyright 2024 James Ketrenos
|
||||
Files: projects/** - not covered by this LICENSE file.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
156
README.md
156
README.md
@ -1,55 +1,59 @@
|
||||
# Android Development Container
|
||||
|
||||
This sets up development containers for Expo and Flutter using
|
||||
the Android SDK. The Dockerfile is derived from parts of [thyrlian/android-sdk](https://github.com/thyrlian/AndroidSDK), with expo and flutter development
|
||||
infrastructure configured as well.
|
||||
This sets up development containers for Expo and Flutter using the
|
||||
Android SDK. The Dockerfile is derived from parts of
|
||||
[thyrlian/android-sdk](https://github.com/thyrlian/AndroidSDK), with
|
||||
expo and flutter development infrastructure configured as well.
|
||||
|
||||
## Build the Android SDK base container
|
||||
## Build the Android SDK development container environment
|
||||
|
||||
This will seed the base container with an initial version of the Android SDK.
|
||||
The following steps will set up an Android build environment:
|
||||
|
||||
```bash
|
||||
docker compose build
|
||||
```
|
||||
1. Seed `android-sdk-manager` container with an initial version of the Android
|
||||
SDK:
|
||||
|
||||
This will build the base 'android-sdk-manager' container as well as the unseeded
|
||||
'android-dev-container'.
|
||||
```bash
|
||||
docker compose build
|
||||
```
|
||||
|
||||
Inside the 'anrdoid-sdk-manager' container the directory '/sdk' will contain the original SDK.
|
||||
This will build the base 'android-sdk-manager' container as well create an unseeded 'android-dev-container'.
|
||||
|
||||
After it is created, the SDK is copied to a volume bind mount on the host to
|
||||
allow multiple containers to use the same base SDK, as well as to perform
|
||||
SDK updates, upgrades, and additional package installations. The initial
|
||||
seeding of the AndroidSDK on the host is performed via:
|
||||
2. Transfer the AndroidSDK from `android-sdk-manager` to the host:
|
||||
|
||||
```bash
|
||||
docker compose run -it --rm \
|
||||
android-sdk-manager \
|
||||
init
|
||||
```
|
||||
Copy the sdk from the android-sdk-manager to the host to allow multiple
|
||||
containers to use the same base SDK, as well as to perform SDK updates,
|
||||
upgrades, and additional package installations.
|
||||
|
||||
## Install packages into SDK
|
||||
```bash
|
||||
docker compose run -it --rm \
|
||||
-v $(realpath AndroidSDK):/sdk:rw \
|
||||
-v $(realpath scripts):/scripts:rw \
|
||||
android-sdk-manager \
|
||||
init
|
||||
```
|
||||
|
||||
The following will install Android platform 34:
|
||||
3. Install packages into SDK
|
||||
|
||||
https://docs.flutter.dev/get-started/install/linux/android?tab=physical#configure-android-development
|
||||
The `android-sdk-manager` container can then be used to update then
|
||||
`./AndroidSDK` on the host to include additional packages.
|
||||
|
||||
The following will install Android platform 35:
|
||||
|
||||
```bash
|
||||
docker compose run -it --rm \
|
||||
android-sdk-manager -- \
|
||||
sdkmanager \
|
||||
"emulator" \
|
||||
"cmdline-tools;latest" \
|
||||
"build-tools;34.0.0" \
|
||||
"platforms;android-34" \
|
||||
"platform-tools" \
|
||||
"system-images;android-34;google_apis_playstore;x86_64"
|
||||
```
|
||||
```bash
|
||||
ANDROID_PLATFORM=35
|
||||
docker compose run -it --rm \
|
||||
-v $(realpath AndroidSDK):/opt/android-sdk:rw \
|
||||
-v $(realpath scripts):/scripts:rw \
|
||||
android-sdk-manager -- \
|
||||
sdkmanager \
|
||||
"build-tools;${ANDROID_PLATFORM}.0.0" \
|
||||
"platforms;android-${ANDROID_PLATFORM}" \
|
||||
"platform-tools"
|
||||
```
|
||||
|
||||
At this point, ./AndroidSDK contains the latest SDK. The docker-compose.yml
|
||||
for the android-dev-container will mount ./AndroidSDK to /opt/android-sdk.
|
||||
At this point, `./AndroidSDK` contains the latest SDK with the requested Android Platform version.
|
||||
|
||||
## Seed the flutter repository
|
||||
## Seed a flutter repository
|
||||
|
||||
```
|
||||
git clone https://github.com/flutter/flutter.git
|
||||
@ -83,3 +87,81 @@ PROJECT=foo
|
||||
```bash
|
||||
docker compose stop "${PROJECT}"
|
||||
```
|
||||
|
||||
|
||||
# Things
|
||||
|
||||
To use virtual devices:
|
||||
|
||||
## Build Eikona
|
||||
|
||||
```bash
|
||||
./launch.sh eikona
|
||||
./shell.sh eikona
|
||||
./build.sh debug # release, or empty
|
||||
```
|
||||
|
||||
## Install base image
|
||||
|
||||
```
|
||||
sdkmanager "system-images;android-35-ext14;google_apis_playstore;x86_64"
|
||||
```
|
||||
|
||||
## Create virtual device
|
||||
|
||||
```
|
||||
avdmanager create avd \
|
||||
-n Pixel \
|
||||
-d pixel_6a \
|
||||
-k "system-images;android-35-ext14;google_apis_playstore;x86_64"
|
||||
```
|
||||
|
||||
# Emulator
|
||||
|
||||
## Run the emulator
|
||||
|
||||
Launch the development container
|
||||
|
||||
```bash
|
||||
./launch.sh eikona
|
||||
```
|
||||
|
||||
## Launch the emulator
|
||||
|
||||
```bash
|
||||
./shell.sh eikona
|
||||
./emulator.sh Pixel
|
||||
```
|
||||
|
||||
## Install the app
|
||||
|
||||
```bash
|
||||
./shell.sh eikona
|
||||
./install.sh debug # or release -- default debug
|
||||
```
|
||||
|
||||
# Add a new component
|
||||
|
||||
## Shell in and add component
|
||||
|
||||
```bash
|
||||
./shell.sh eikona
|
||||
npx expo install react-pdf-viewer
|
||||
```
|
||||
|
||||
### To remove
|
||||
|
||||
```bash
|
||||
./shell.sh eikona
|
||||
npm remove react-pdf-viewer
|
||||
```
|
||||
|
||||
## Build the app
|
||||
|
||||
While in the shell previously launched, run the 'build' script:
|
||||
|
||||
```bash
|
||||
./shell.sh eikona
|
||||
./build.sh debug # release
|
||||
```
|
||||
|
||||
|
34
debug.sh
Executable file
34
debug.sh
Executable file
@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
fail() {
|
||||
echo "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
declare project_type=$1
|
||||
declare project=$2
|
||||
|
||||
if [[ "${project}" == "" ]] || [[ "${project_type}" == "" ]]; then
|
||||
echo "usage: $0 expo|flutter PROJECT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "projects/${project}" ]]; then
|
||||
if ! mkdir -p "projects/${project}"; then
|
||||
fail "mkdir -p projects/${project}"
|
||||
fi
|
||||
fi
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose run -it --rm \
|
||||
--name "${project}-seed" \
|
||||
-v $(pwd)/scripts:/scripts \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
-v $(pwd)/AndroidUser:/root/.android \
|
||||
-v $(pwd)/GradleUser:/root/.gradle \
|
||||
-v "${full_path}:/projects/${project}" \
|
||||
android-dev-container -- \
|
||||
shell; then
|
||||
fail "Unable to run seed-project for ${project}"
|
||||
else
|
||||
echo "Project '${project}' now exists in projects/${project}"
|
||||
fi
|
16
develop.sh
16
develop.sh
@ -14,12 +14,12 @@ fi
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose run -it --rm \
|
||||
--name "${project}-seed" \
|
||||
-v "${full_path}:/projects/${project}" \
|
||||
-p 5920:5920 \
|
||||
-e CONTAINER="${project}" \
|
||||
android-dev-container -- \
|
||||
develop \
|
||||
"${project}"; then
|
||||
fail "Unable to launch development container for ${project}"
|
||||
--name "${project}-seed" \
|
||||
-v $(pwd)/AndroidUser:/root/.android \
|
||||
-v $(pwd)/GradleUser:/root/.gradle \
|
||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||
-v "${full_path}:/projects/${project}" \
|
||||
android-dev-container -- \
|
||||
develop "${project}"; then
|
||||
fail "Unable to launch development container for ${project}"
|
||||
fi
|
||||
|
@ -2,8 +2,6 @@ services:
|
||||
android-sdk-manager:
|
||||
build:
|
||||
context: .
|
||||
environment:
|
||||
- CONTAINER_MODE=android-sdk-manager
|
||||
tty: true
|
||||
ports:
|
||||
- '5037:5037'
|
||||
@ -11,23 +9,23 @@ services:
|
||||
- ./AndroidSDK:/sdk:rw
|
||||
# - ./AndroidSDK:/opt/android-sdk:rw
|
||||
- ./scripts:/scripts:rw
|
||||
- ./devices:/opt/devices:rw
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
android-dev-container:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
- NODE_ENV=development
|
||||
privileged: true
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
tty: true
|
||||
ports:
|
||||
- '8081:8081' # expo web browser
|
||||
- '19006:19006'
|
||||
- '19001:19001'
|
||||
- '19002:19002'
|
||||
- '5920:5920'
|
||||
devices:
|
||||
- /dev/kvm
|
||||
volumes:
|
||||
- ./react_native_app:/opt/react_native_app/app:delegated
|
||||
- ./react_native_app/package.json:/opt/react_native_app/package.json
|
||||
@ -35,12 +33,8 @@ services:
|
||||
- ./flutter:/usr/bin/flutter
|
||||
- notused:/opt/react_native_app/app/node_modules
|
||||
- ./repos:/opt/repos
|
||||
# - ./AndroidSDK:/opt/android-sdk:ro
|
||||
- ./AndroidSDK:/opt/android-sdk:ro
|
||||
- ./AndroidSDK:/opt/android-sdk:rw
|
||||
- ./scripts:/scripts:rw
|
||||
- ./devices:/opt/devices:rw
|
||||
- ./cache/pub-cache:/root/.pub-cache:rw
|
||||
- ./cache/android:/root/.android:rw
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
|
5
env.sh
Normal file
5
env.sh
Normal file
@ -0,0 +1,5 @@
|
||||
ANDROID_HOME=$(pwd)/AndroidSDK
|
||||
ANDROID_AVD_HOME=$(pwd)/AndroidUser/avd
|
||||
ANDROID_USER_HOME=$(pwd)/AndroidUser
|
||||
GRADLE_HOME=$(pwd)/GradleUser
|
||||
PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/emulator
|
52
launch.sh
52
launch.sh
@ -13,13 +13,49 @@ fi
|
||||
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose run --rm \
|
||||
--name "${project}-seed" \
|
||||
-v "${full_path}:/projects/${project}" \
|
||||
-p 5920:5920 \
|
||||
-e CONTAINER="${project}" \
|
||||
android-dev-container -- \
|
||||
run \
|
||||
"${project}"; then
|
||||
declare project_type=$(cat "${full_path}/project_type")
|
||||
|
||||
if [[ "${project_type}" == "expo" ]]; then
|
||||
echo "Launching EXPO container"
|
||||
ports=(
|
||||
"8081:8081"
|
||||
)
|
||||
volumes=(
|
||||
./flutter:/usr/bin/flutter
|
||||
./AndroidSDK:/opt/android-sdk:rw
|
||||
./scripts:/scripts:rw
|
||||
/tmp/.X11-unix:/tmp/.X11-unix
|
||||
$(pwd)/AndroidUser:/root/.android
|
||||
$(pwd)/GradleUser:/root/.gradle
|
||||
)
|
||||
fi
|
||||
|
||||
# Always add the project volume mount
|
||||
volumes=("${volumes[@]}" "${full_path}:/projects/${project}")
|
||||
|
||||
if [ ${#ports[@]} -ne 0 ]; then
|
||||
port_arg=""
|
||||
for port in "${ports[@]}"; do
|
||||
port_arg="${port_arg} -p ${port}"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${#volumes[@]} -ne 0 ]; then
|
||||
volume_arg=""
|
||||
for volume in "${volumes[@]}"; do
|
||||
volume_arg="${volume_arg} -v ${volume}"
|
||||
done
|
||||
fi
|
||||
|
||||
# --privileged is needed to be able to run the emulator
|
||||
docker_cmd="docker compose run --rm
|
||||
--name ${project}-seed
|
||||
${port_arg}
|
||||
${volume_arg}
|
||||
android-dev-container --
|
||||
run ${project} $(hostname)"
|
||||
|
||||
echo "${docker_cmd}"
|
||||
if ! ${docker_cmd}; then
|
||||
fail "Unable to start container for ${project}"
|
||||
fi
|
||||
|
@ -29,8 +29,6 @@ accept_all_android_licenses() {
|
||||
accept_license_of android-sdk-preview-license 504667f4c0de7af1a06de9f4b1727b84351f2910
|
||||
accept_license_of google-gdk-license 33b6a2b64607f11b759f320ef9dff4ae5c47d97a
|
||||
accept_license_of intel-android-extra-license d975f751698a77b662f1254ddbeed3901e976f5a
|
||||
accept_license_of android-sdk-arm-dbt-license 859f317696f67ef3d7f30a50a5560e7834b43903
|
||||
accept_license_of mips-android-sysimage-license e9acab5b5fbb560a72cfaecce8946896ff6aab9d
|
||||
}
|
||||
|
||||
accept_license_of() {
|
||||
|
0
projects/.keep
Normal file
0
projects/.keep
Normal file
@ -9,8 +9,6 @@ arguments=(
|
||||
declare -i parse_error=0
|
||||
declare command=""
|
||||
|
||||
declare XVNC_ARGS="-depth 24 -geometry 1280x1024 -ac"
|
||||
|
||||
#
|
||||
# Parse command line arguments
|
||||
#
|
||||
@ -62,12 +60,29 @@ if (( parse_error )); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
runtime_config() {
|
||||
export project=$1
|
||||
if [[ "${2}" != "" ]]; then
|
||||
export REACT_NATIVE_PACKAGER_HOSTNAME="${2}"
|
||||
fi
|
||||
export project_type=$(cat "/projects/${project}/project_type")
|
||||
cd "/projects/${project}"
|
||||
echo "Setting safe.directory on ${PWD}"
|
||||
git config --global --add safe.directory "${PWD}"
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
# echo "Installing expo..."
|
||||
# npm install -g expo
|
||||
# echo "Installing expo-doctor..."
|
||||
# npx expo install expo-doctor
|
||||
;;
|
||||
"flutter")
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "${command}" in
|
||||
init)
|
||||
if [[ "${CONTAINER_MODE}" != "android-sdk-manager" ]]; then
|
||||
fail "'${command}' must be run on android-sdk-manager not android-dev-container"
|
||||
fi
|
||||
|
||||
if [[ ! -e "${ANDROID_HOME}"/license/android-sdk-license ]]; then
|
||||
if ! cp -a "${ANDROID_HOME}"/. /sdk; then
|
||||
fail "Unable to copy ${ANDROID_HOME} to /sdk"
|
||||
@ -77,99 +92,44 @@ init)
|
||||
;;
|
||||
|
||||
seed-project)
|
||||
if [[ "${CONTAINER_MODE}" == "android-sdk-manager" ]]; then
|
||||
fail "'${command}' must be run on android-dev-container not android-sdk-manager"
|
||||
fi
|
||||
seed-project "${options[@]}"
|
||||
exit $?
|
||||
;;
|
||||
seed-project "${options[@]}"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
develop)
|
||||
if [[ "${CONTAINER_MODE}" == "android-sdk-manager" ]]; then
|
||||
fail "'${command}' must be run on android-dev-container not android-sdk-manager"
|
||||
fi
|
||||
project="${1}"
|
||||
project_type=$(cat "/projects/${project}/project_type")
|
||||
cd "/projects/${project}"
|
||||
if [[ -d ".git" ]]; then
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
fi
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
echo "Launching web app in ${project}"
|
||||
npm run web
|
||||
;;
|
||||
"flutter")
|
||||
cat << EOF > ~/.flutter
|
||||
{
|
||||
"firstRun": false,
|
||||
"clientId": "b88ac7f3-4d6f-41e0-bef6-f377e4eaceb7",
|
||||
"enabled": false
|
||||
}
|
||||
EOF
|
||||
Xvnc ${DISPLAY} ${XVNC_ARGS} >/dev/null 2>&1 &
|
||||
fluxbox >/dev/null 2>&1 &
|
||||
echo "X11 VNC running on ${DISPLAY} with password '${CONTAINER}'"
|
||||
if [[ ! -d "/opt/devices/pixel-6a" ]]; then
|
||||
echo "Creating Pixel 6A with Android 35 and Google APIs"
|
||||
avdmanager create avd --force --path /opt/devices/pixel-6a --name Pixel-6a -k "system-images;android-34;google_apis_playstore;x86_64" --device pixel_6a
|
||||
fi
|
||||
echo "Launching emulator. Connect via vnc to view."
|
||||
emulator -avd Pixel-6a &
|
||||
echo "Launching terminal in ${project}"
|
||||
/bin/bash
|
||||
;;
|
||||
esac
|
||||
runtime_config ${1} ${2}
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
echo "Launching terminal in ${project}"
|
||||
/bin/bash
|
||||
;;
|
||||
"flutter")
|
||||
echo "Launching terminal in ${project}"
|
||||
/bin/bash
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
run)
|
||||
if [[ "${CONTAINER_MODE}" == "android-sdk-manager" ]]; then
|
||||
fail "'${command}' must be run on android-dev-container not android-sdk-manager"
|
||||
fi
|
||||
project="${1}"
|
||||
cd "/projects/${project}"
|
||||
if [[ -d ".git" ]]; then
|
||||
git config --global --add safe.directory "$(pwd)"
|
||||
fi
|
||||
project_type=$(cat "/projects/${project}/project_type")
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
echo "Starting web app in ${project}"
|
||||
while true; do npm run web; sleep 5; done
|
||||
;;
|
||||
"flutter")
|
||||
cat << EOF > ~/.flutter
|
||||
{
|
||||
"firstRun": false,
|
||||
"clientId": "b88ac7f3-4d6f-41e0-bef6-f377e4eaceb7",
|
||||
"enabled": false
|
||||
}
|
||||
EOF
|
||||
Xvnc ${DISPLAY} ${XVNC_ARGS} >/dev/null 2>&1 &
|
||||
fluxbox >/dev/null 2>&1 &
|
||||
echo "X11 VNC running on ${DISPLAY} with password '${CONTAINER}'"
|
||||
if [[ ! -d "/opt/devices/pixel-6a" ]]; then
|
||||
echo "Creating Pixel 6A with Android 35 and Google APIs"
|
||||
avdmanager create avd --force --path /opt/devices/pixel-6a --name Pixel-6a -k "system-images;android-34;google_apis_playstore;x86_64" --device pixel_6a
|
||||
fi
|
||||
echo "Launching emulator. Connect via vnc to view."
|
||||
emulator -avd Pixel-6a &
|
||||
echo "Launching terminal in ${project}"
|
||||
/bin/bash
|
||||
;;
|
||||
esac
|
||||
runtime_config ${1} ${2}
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
echo "Starting expo app in ${project}"
|
||||
while true; do npx expo start; sleep 5; done
|
||||
;;
|
||||
"flutter")
|
||||
echo "Launching terminal in ${project}"
|
||||
/bin/bash
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*bash|shell)
|
||||
/bin/bash "${options[@]}"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
*)
|
||||
if [[ "${CONTAINER_MODE}" == "android-sdk-manager" ]] && [[ "${command}" =~ .*sdkmanager$ ]]; then
|
||||
echo "'${command}' detected. Updating container copy of Android SDK from the host."
|
||||
cp -a /sdk/. $ANDROID_HOME/
|
||||
fi
|
||||
${command} "${@}"
|
||||
if [[ "${CONTAINER_MODE}" == "android-sdk-manager" ]] && [[ "${command}" =~ .*sdkmanager$ ]]; then
|
||||
echo "'${command}' detected. Updating host copy of Android SDK"
|
||||
cp -a $ANDROID_HOME/. /sdk/
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
@ -33,7 +33,7 @@ while (( $# > 0 )); do
|
||||
# Uncomment to help debug case statement:
|
||||
# echo "Processing: \$1='$1' \$2='$2'"
|
||||
case "${1}" in
|
||||
-h|--help) # Help / usage
|
||||
-h|--help) # Help / usage
|
||||
usage_extra="[PROJECT]"
|
||||
default_usage
|
||||
exit 0
|
||||
@ -87,17 +87,32 @@ case "${project_type}" in
|
||||
#
|
||||
# 'npx expo init' was replaced with 'npx create-expo-app'
|
||||
#
|
||||
echo "Seeding expo project ${project} in $(pwd)/${project}..."
|
||||
if ! npx create-expo-app "${project}"; then
|
||||
echo "Seeding expo project ${project} in $(pwd)/${project} (answer 'y' if prompted)..."
|
||||
if ! npx create-expo-app -y "${project}"; then
|
||||
fail "npx create-expo-app ${project}"
|
||||
fi
|
||||
|
||||
cd "${project}"
|
||||
|
||||
if ! npx expo install react-native-web react-dom @expo/webpack-config; then
|
||||
fail "npx expo install react-native-web react-dom @expo/webpack-config"
|
||||
if [[ ! -d install ]]; then
|
||||
mkdir install
|
||||
fi
|
||||
|
||||
echo "Installing react and webpack into expo environment..."
|
||||
|
||||
npm install -g eas-cli
|
||||
|
||||
pkgs=(
|
||||
react-native-web
|
||||
react-dom
|
||||
expo-dev-client
|
||||
)
|
||||
# @expo/webpack-config
|
||||
for pkg in "${pkgs[@]}"; do
|
||||
if ! npx expo install "${pkg}"; then
|
||||
fail "npx expo install ${pkg}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Installing node packages..."
|
||||
if ! npm install; then
|
||||
fail "npm install"
|
||||
@ -109,6 +124,7 @@ case "${project_type}" in
|
||||
|
||||
echo "${project_type}" > project_type
|
||||
;;
|
||||
|
||||
"flutter")
|
||||
ls -altr /usr/bin/flutter
|
||||
declare version="flutter_linux_3.22.2-stable.tar.xz"
|
||||
@ -123,9 +139,6 @@ case "${project_type}" in
|
||||
fi
|
||||
fi
|
||||
git config --global --add safe.directory /usr/bin/flutter
|
||||
flutter config --no-analytics
|
||||
flutter config --disable-analytics
|
||||
flutter doctor --android-licenses
|
||||
cd "${project}"
|
||||
if ! chown -R ${user}:${group} .; then
|
||||
fail "chown -R ${user}:${group} ."
|
||||
|
8
seed.sh
8
seed.sh
@ -26,9 +26,11 @@ if ! docker compose run -it --rm \
|
||||
android-dev-container -- \
|
||||
seed-project \
|
||||
"${project_type}" \
|
||||
-u $(id -u) \
|
||||
-g $(id) \
|
||||
"${project}"; then
|
||||
"${project}" \
|
||||
-- \
|
||||
-u $(id -u) \
|
||||
-g $(id) \
|
||||
; then
|
||||
fail "Unable to run seed-project for ${project}"
|
||||
else
|
||||
echo "Project '${project}' now exists in projects/${project}"
|
||||
|
12
shell.sh
12
shell.sh
@ -7,15 +7,15 @@ fail() {
|
||||
declare project=$1
|
||||
|
||||
if [[ "${project}" == "" ]]; then
|
||||
echo "usage: ${0} PROJECT" >&2
|
||||
echo "usage: $0 PROJECT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose exec -it \
|
||||
"${project}" \
|
||||
shell; then
|
||||
fail "Unable to launch shell in '${project}'. Make sure it is running via './launch.sh ${project}'."
|
||||
if ! docker exec -it \
|
||||
-w "/projects/${project}" \
|
||||
${project}-seed \
|
||||
/bin/bash; then
|
||||
fail "Unable to launch shell in ${project}-seed"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user