diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..719f96f --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:22.04 + +# Set environment variables +ENV FLUTTER_HOME=/opt/flutter +ENV PATH="$FLUTTER_HOME/bin:$PATH" +ENV PUB_CACHE=/opt/pub-cache + +# Install system dependencies including Node.js +# Nodejs is required for the forgejo runner (checkout action) +RUN apt-get update && apt-get install -y \ + curl \ + git \ + wget \ + unzip \ + ca-certificates \ + gnupg \ + && mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ + && apt-get update \ + && apt-get install -y nodejs \ + && rm -rf /var/lib/apt/lists/* + +# Install Flutter +RUN git clone https://github.com/flutter/flutter.git $FLUTTER_HOME \ + && flutter doctor \ + && flutter channel stable \ + && flutter upgrade \ + && flutter config --enable-web \ + && flutter precache --web + +# Create cache directories +RUN mkdir -p $PUB_CACHE + +WORKDIR /workspace diff --git a/.forgejo/workflows/main-build.yaml b/.forgejo/workflows/main-build.yaml index 687019b..186e350 100644 --- a/.forgejo/workflows/main-build.yaml +++ b/.forgejo/workflows/main-build.yaml @@ -5,37 +5,34 @@ on: jobs: build-web: + # custom runner image -> includes node and latest flutter stable runs-on: flutter-web-builder steps: - - name: install node - id: node-install - run: | - apt update - apt install -y ca-certificates curl gnupg - mkdir -p /etc/apt/keyrings - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list - apt update - apt install -y nodejs - flutter channel stable - flutter upgrade - - name: Checkout code uses: actions/checkout@v4 - - name: Cache Flutter - id: cache-flutter - uses: actions/cache@v4 - with: - path: ${{ forge.workspace }}/../.tool-cache - key: ${{ forge.ref_name }}-flutter-cache-temp - + # Cache pub dependencies (this should work now) - name: Cache pub dependencies uses: actions/cache@v4 id: cache-pub with: - path: ${{ forge.workspace }}/../.pub-cache - key: ${{ forge.ref_name }}-pub-cache-temp + path: /opt/pub-cache + key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} + restore-keys: | + ${{ runner.os }}-pub- + + # Cache build outputs and tool cache + - name: Cache Flutter build + uses: actions/cache@v4 + with: + path: | + .dart_tool + build + key: ${{ runner.os }}-flutter-build-${{ hashFiles('**/pubspec.lock') }}-${{ hashFiles('lib/**/*.dart') }} + restore-keys: | + ${{ runner.os }}-flutter-build-${{ hashFiles('**/pubspec.lock') }}- + ${{ runner.os }}-flutter-build- + - name: Get dependencies run: flutter pub get