Updating to work with latest expo
Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
parent
bf80f5e5ec
commit
1cba45c7b9
23
Dockerfile
23
Dockerfile
@ -124,4 +124,27 @@ RUN apt-get update \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/{apt,dpkg,cache,log}
|
||||
|
||||
# Install build-essential, which includes g++ (required)
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
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 \
|
||||
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
|
||||
|
104
README.md
104
README.md
@ -1,66 +1,64 @@
|
||||
# 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 35.
|
||||
3. Install packages into SDK
|
||||
|
||||
```bash
|
||||
ANDROID_PLATFORM=35
|
||||
docker compose run -it --rm \
|
||||
android-sdk-manager -- \
|
||||
sdkmanager \
|
||||
"build-tools;${ANDROID_PLATFORM}.0.0" \
|
||||
"platforms;android-${ANDROID_PLATFORM}" \
|
||||
"platform-tools"
|
||||
```
|
||||
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:
|
||||
|
||||
At this point, ./AndroidSDK contains the latest SDK. The docker-compose.yml
|
||||
for the android-dev-container will mount ./AndroidSDK to /opt/android-sdk.
|
||||
```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"
|
||||
```
|
||||
|
||||
### Copy the base SDK to the mounted 'sdk' directory
|
||||
At this point, `./AndroidSDK` contains the latest SDK with the requested Android Platform version.
|
||||
|
||||
```bash
|
||||
docker compose run -it --rm \
|
||||
android-dev-container -- \
|
||||
bash -c 'cp -a $ANDROID_HOME/. /sdk/'
|
||||
```
|
||||
|
||||
## Seed the flutter repository
|
||||
## Seed a flutter repository
|
||||
|
||||
```
|
||||
git clone https://github.com/flutter/flutter.git
|
||||
```
|
||||
|
||||
|
||||
|
||||
## To seed a new project (once per project)
|
||||
|
||||
```bash
|
||||
@ -89,3 +87,23 @@ PROJECT=foo
|
||||
```bash
|
||||
docker compose stop "${PROJECT}"
|
||||
```
|
||||
|
||||
|
||||
# Things
|
||||
|
||||
To use virtual devices:
|
||||
|
||||
## 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"
|
||||
```
|
33
debug.sh
Executable file
33
debug.sh
Executable file
@ -0,0 +1,33 @@
|
||||
#!/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 "${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
|
13
develop.sh
13
develop.sh
@ -14,10 +14,11 @@ fi
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose run -it --rm \
|
||||
--name "${project}-seed" \
|
||||
-v "${full_path}:/projects/${project}" \
|
||||
android-dev-container -- \
|
||||
develop \
|
||||
"${project}"; then
|
||||
fail "Unable to launch development container for ${project}"
|
||||
--name "${project}-seed" \
|
||||
-v $(pwd)/AndroidUser:/root/.android \
|
||||
-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
|
||||
|
@ -17,10 +17,12 @@ services:
|
||||
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'
|
||||
@ -31,10 +33,10 @@ 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:rw
|
||||
- ./scripts:/scripts:rw
|
||||
healthcheck:
|
||||
disable: true
|
||||
|
||||
volumes:
|
||||
notused:
|
||||
notused:
|
||||
|
4
env.sh
Normal file
4
env.sh
Normal file
@ -0,0 +1,4 @@
|
||||
ANDROID_HOME=$(pwd)/AndroidSDK
|
||||
ANDROID_AVD_HOME=$(pwd)/AndroidUser/avd
|
||||
ANDROID_USER_HOME=$(pwd)/AndroidUser
|
||||
PATH=$PATH:$ANDROID_HOME/cmdline-tools/tools/bin:$ANDROID_HOME/emulator
|
49
launch.sh
49
launch.sh
@ -13,11 +13,48 @@ fi
|
||||
|
||||
declare full_path=$(realpath "projects/${project}")
|
||||
|
||||
if ! docker compose run --rm \
|
||||
--name "${project}-seed" \
|
||||
-v "${full_path}:/projects/${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
|
||||
)
|
||||
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
|
||||
|
@ -60,6 +60,27 @@ 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 [[ ! -e "${ANDROID_HOME}"/license/android-sdk-license ]]; then
|
||||
@ -71,43 +92,43 @@ init)
|
||||
;;
|
||||
|
||||
seed-project)
|
||||
seed-project "${options[@]}"
|
||||
exit $?
|
||||
;;
|
||||
seed-project "${options[@]}"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
develop)
|
||||
project="${1}"
|
||||
project_type=$(cat "/projects/${project}/project_type")
|
||||
cd "/projects/${project}"
|
||||
case "${project_type}" in
|
||||
"expo")
|
||||
echo "Launching web app in ${project}"
|
||||
npm run web
|
||||
;;
|
||||
"flutter")
|
||||
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)
|
||||
project="${1}"
|
||||
cd "/projects/${project}"
|
||||
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")
|
||||
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 $?
|
||||
;;
|
||||
|
||||
*)
|
||||
${command} "${@}"
|
||||
;;
|
||||
|
@ -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"
|
||||
|
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}"
|
||||
|
11
shell.sh
11
shell.sh
@ -7,15 +7,14 @@ 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 \
|
||||
${project}-seed \
|
||||
/bin/bash; then
|
||||
fail "Unable to launch shell in ${project}-seed"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user