Last active
August 12, 2024 08:51
-
-
Save Kr328/25a75409a038b93f71b7020c3b2cb66e to your computer and use it in GitHub Desktop.
A dockerfile to create a flutter build enviroment on windows-x64 with scoop & rust.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTE: This Dockerfile requires Windows containers support. | |
# See also: https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment | |
# | |
# NOTE: Windows Containers run by default with 2 CPUs and 2GB of memory. If you need more resources, try specifying the following parameters: | |
# 1. --cpu-count | |
# 2. --memory | |
# Example: docker run --cpu-count 16 --memory 8gb <your-tag> -Command flutter build | |
FROM mcr.microsoft.com/windows/servercore:ltsc2022 | |
SHELL ["powershell.exe", "-ExecutionPolicy", "Bypass", "-Command"] | |
# Download channel for fixed install. | |
ARG CHANNEL_URL=https://aka.ms/vs/17/release/channel | |
ADD ${CHANNEL_URL} "C:\\TEMP\\VisualStudio.chman" | |
# Download and install Build Tools for Visual Studio 2022 for native desktop workload. | |
ADD https://aka.ms/vs/17/release/vs_buildtools.exe "C:\\TEMP\\vs_buildtools.exe" | |
RUN C:\\TEMP\\vs_buildtools.exe --quiet --wait --norestart --nocache \ | |
--channelUri C:\\TEMP\\VisualStudio.chman \ | |
--installChannelUri C:\\TEMP\\VisualStudio.chman \ | |
--add Microsoft.VisualStudio.Workload.VCTools --includeRecommended \ | |
--installPath C:\\BuildTools | |
# Configure powershell restore enviroments on start | |
RUN New-Item -Path $PROFILE -Type File -Force | |
RUN Set-Content -Path $PROFILE -Value "\"[System.Environment]::SetEnvironmentVariable('Path', [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';' + [System.Environment]::GetEnvironmentVariable('Path', 'Machine'))\"" | |
# Enforce system trust store up-to-date | |
RUN Invoke-WebRequest -Uri https://pub.dev/ -UseBasicParsing | |
# Install dependencies | |
ADD https://get.scoop.sh "C:\\TEMP\\scoop-installer.ps1" | |
RUN C:\\TEMP\\scoop-installer.ps1 -RunAsAdmin | |
RUN scoop install git | |
RUN scoop bucket add extras | |
RUN scoop install unzip zip protobuf rustup cmake busybox llvm | |
# Configure git | |
RUN git config --global --add safe.directory '*' | |
# Install rust | |
ARG RUST_VERSION | |
RUN rustup default "${RUST_VERSION}" | |
# Install flutter | |
ARG FLUTTER_URL | |
ADD "${FLUTTER_URL}" "C:\\TEMP\\flutter.zip" | |
RUN unzip -d "C:\\" "C:\\TEMP\\flutter.zip" | |
RUN "[System.Environment]::SetEnvironmentVariable('Path', [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';C:\flutter\bin', 'User')" | |
RUN flutter doctor | |
# Cleanup installers | |
RUN Remove-Item -LiteralPath C:\\TEMP -Recurse -Force | |
# Start PowerShell | |
ENTRYPOINT ["powershell.exe", "-ExecutionPolicy", "Bypass"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment