Skip to content

Instantly share code, notes, and snippets.

@Kr328
Last active May 8, 2024 18:47
Show Gist options
  • Save Kr328/25a75409a038b93f71b7020c3b2cb66e to your computer and use it in GitHub Desktop.
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.
# 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'))\""
# 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
# Cleanup installers
RUN Remove-Item -LiteralPath C:\\TEMP -Recurse -Force
# Configure git
RUN git config --global --add safe.directory '*'
# Install rust
RUN rustup default stable
# Install flutter
RUN git clone --branch stable https://github.com/flutter/flutter.git C:\\flutter
RUN "[System.Environment]::SetEnvironmentVariable('Path', [System.Environment]::GetEnvironmentVariable('Path', 'User') + ';C:\flutter\bin', 'User')"
RUN flutter doctor
# 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