flutterw, like gradle wrapper for flutter, in a container
This commit is contained in:
parent
dae8fe1ece
commit
6f352a945c
3 changed files with 51 additions and 21 deletions
16
Makefile
16
Makefile
|
|
@ -2,28 +2,28 @@
|
|||
all: clean-container build-linux-debug-container
|
||||
|
||||
build-container:
|
||||
./docker-exec.sh build
|
||||
./flutterw --build
|
||||
|
||||
clean-container: build-container
|
||||
./docker-exec.sh exec flutter clean
|
||||
./flutterw clean
|
||||
|
||||
pub-get-container: build-container
|
||||
./docker-exec.sh exec flutter pub get
|
||||
./flutterw pub get
|
||||
|
||||
build-android-release-container: pub-get-container
|
||||
./docker-exec.sh exec flutter build apk --release
|
||||
./flutterw build apk --release
|
||||
|
||||
build-linux-debug-container: pub-get-container
|
||||
./docker-exec.sh exec flutter build linux --debug
|
||||
./flutterw build linux --debug
|
||||
|
||||
build-web-debug-container: pub-get-container
|
||||
./docker-exec.sh exec flutter build web --debug
|
||||
./flutterw build web --debug
|
||||
|
||||
run-linux-debug-container: pub-get-container
|
||||
./docker-exec.sh exec flutter run -d linux
|
||||
./flutterw run -d linux
|
||||
|
||||
run-web-debug-container: pub-get-container
|
||||
./docker-exec.sh exec flutter run --web-port $${WEB_PORT:-8081} -d web-server
|
||||
./flutterw run --web-port $${WEB_PORT:-8081} -d web-server
|
||||
|
||||
run-linux-debug-native: build-linux-debug-container
|
||||
./build/linux/x64/debug/bundle/d4rt_formulas
|
||||
|
|
|
|||
31
docker/Dockerfile
Normal file
31
docker/Dockerfile
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
FROM ghcr.io/cirruslabs/flutter:stable
|
||||
|
||||
# Install cmake, ninja, clang, pkg-config for flutter linux
|
||||
RUN apt-get update && apt-get install -y cmake ninja-build clang pkg-config libgtk-3-dev liblzma-dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Configure cache directories
|
||||
ENV PUB_CACHE=/cache/pub-cache
|
||||
ENV GRADLE_USER_HOME=/cache/gradle-cache
|
||||
RUN mkdir -p $PUB_CACHE $GRADLE_USER_HOME
|
||||
|
||||
# To avoid: fatal: detected dubious ownership in repository at '/sdks/flutter'
|
||||
# Pass this during build: --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)
|
||||
ARG USER_ID
|
||||
ARG GROUP_ID
|
||||
RUN echo "Using UID: $USER_ID and GID: $GROUP_ID"
|
||||
RUN chown -R $USER_ID:$GROUP_ID $PUB_CACHE $GRADLE_USER_HOME
|
||||
RUN chown -R $USER_ID:$GROUP_ID /sdks/flutter
|
||||
|
||||
USER $USER_ID:$GROUP_ID
|
||||
|
||||
# Copy pubspec files and get dependencies
|
||||
# Commented out to avoid building the app during image creation, this will be handled externally by makefile
|
||||
# COPY pubspec.yaml pubspec.lock ./
|
||||
# RUN flutter pub get
|
||||
|
||||
# Copy the rest of the application code and build
|
||||
# Commented out to avoid building the app during image creation, this will be handled externally by makefile
|
||||
# COPY . .
|
||||
# RUN flutter build apk --release
|
||||
|
|
@ -4,7 +4,8 @@ set -e
|
|||
set -x
|
||||
|
||||
BUILDCACHE=./.build-container-cache
|
||||
|
||||
DOCKERFILE=./docker/Dockerfile
|
||||
IMAGE=d4rt-formulas-builder
|
||||
|
||||
detect_container(){
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ build_image(){
|
|||
then
|
||||
USERMAPING="--build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g)"
|
||||
fi
|
||||
$DOCKER build $USERMAPING -t d4rt-formulas-builder -f Dockerfile .
|
||||
$DOCKER build $USERMAPING -t $IMAGE -f $DOCKERFILE .
|
||||
}
|
||||
|
||||
graphic_options(){
|
||||
|
|
@ -112,24 +113,22 @@ exec_in_container(){
|
|||
main(){
|
||||
detect_container
|
||||
|
||||
if [ "$1" = "build" ]; then
|
||||
if [ "$1" = "--build" ]; then
|
||||
build_image
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ "$1" = "cleancache" ]; then
|
||||
elif [ "$1" = "--cleancache" ]; then
|
||||
clean_build_cache
|
||||
return $?
|
||||
fi
|
||||
|
||||
|
||||
if [ "$1" = "exec" ]; then
|
||||
elif [ "$1" = "--exec" ]; then
|
||||
exec_in_container ${@:2}
|
||||
return $?
|
||||
elif [ "$1" = "" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||
echo "Usage: $0 {build|cleancache|exec <command>}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Usage: $0 {build|cleancache|exec <command>}"
|
||||
return 1
|
||||
|
||||
exec_in_container flutter ${@:1}
|
||||
return $?
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in a new issue