Skip to content

Commit 3b12598

Browse files
committed
Dev: Preserve more generated files in docker
1 parent 4be192f commit 3b12598

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

.github/docker/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
.dart_tool
2-
.pub-cache
1+
*
2+
!.gitignore
3+
!Dockerfile

.github/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RUN apt-get clean
1313

1414
# Install Flutter
1515
RUN git clone https://github.com/flutter/flutter.git /opt/flutter --branch stable
16+
ENV PUB_CACHE=/root/.pub-cache
1617
RUN mkdir -p /root/.pub-cache/bin/
1718
ENV PATH="/opt/flutter/bin:/root/.pub-cache/bin:$PATH"
1819
RUN flutter precache --no-universal --linux

test.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ if ! docker images --format '{{.Repository}}' | grep -w "$IMAGE_NAME" > /dev/nul
5656
docker build -t "$IMAGE_NAME" -f "$DOCKERFILE_PATH" "$(dirname $DOCKERFILE_PATH)"
5757
fi
5858

59+
# Make sure mounts exist
60+
mkdir -p .github/docker/.pub-cache
61+
mkdir -p .github/docker/.dart_tool
62+
mkdir -p .github/docker/build
63+
touch .github/docker/.flutter-plugins
64+
touch .github/docker/.flutter-plugins-dependencies
65+
touch .github/docker/pubspec.lock
66+
5967
# Start or create container from image
6068
if docker ps -a --format '{{.Names}}' | grep -w "$CONTAINER_NAME" > /dev/null; then
6169
echo "Starting existing container $CONTAINER_NAME"
@@ -70,15 +78,15 @@ else
7078
APP_PATH="$(pwd)"
7179
fi
7280

73-
# Create docker cache directory
74-
mkdir -p .github/docker/.pub-cache
75-
mkdir -p .github/docker/.dart_tool
76-
7781
# Run container
7882
docker run -dit --name "$CONTAINER_NAME" \
7983
-v "$APP_PATH":/app \
80-
-v "$APP_PATH/.github/docker/.pub-cache":/app/.pub-cache \
84+
-v "$APP_PATH/.github/docker/.pub-cache":/root/.pub-cache \
8185
-v "$APP_PATH/.github/docker/.dart_tool":/app/.dart_tool \
86+
-v "$APP_PATH/.github/docker/build":/app/build \
87+
-v "$APP_PATH/.github/docker/.flutter-plugins":/app/.flutter-plugins \
88+
-v "$APP_PATH/.github/docker/.flutter-plugins-dependencies":/app/.flutter-plugins-dependencies \
89+
-v "$APP_PATH/.github/docker/pubspec.lock":/app/pubspec.lock \
8290
"$IMAGE_NAME"
8391
docker exec -it "$CONTAINER_NAME" flutter pub get
8492
fi

0 commit comments

Comments
 (0)