Last active
April 18, 2023 20:29
-
-
Save cornfeedhobo/dafec5c0a39d553983560dc304d08d5b to your computer and use it in GitHub Desktop.
flutter devcontainer example
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
Show hidden characters
{ | |
"name": "Flutter (openSUSE)", | |
"build": { | |
"dockerfile": "Dockerfile", | |
"args": { | |
// Modify for your project's intended platforms. These will be installed at container build time. | |
// Alternatively, this can be a step in postCreateCommand below. | |
"ANDROID_SDK_PACKAGES": "build-tools;33.0.2 platforms;android-33 extras;android;m2repository extras;google;m2repository" | |
} | |
}, | |
"containerEnv": { | |
"DBUS_SESSION_BUS_ADDRESS": "${localEnv:DBUS_SESSION_BUS_ADDRESS}", | |
"DISPLAY": "${localEnv:DISPLAY}" | |
}, | |
"remoteEnv": { | |
"DBUS_SESSION_BUS_ADDRESS": "${localEnv:DBUS_SESSION_BUS_ADDRESS}", | |
"DISPLAY": "${localEnv:DISPLAY}" | |
}, | |
"runArgs": [ | |
// This device is needed for android emulator to interact with kvm acceleration. | |
// It's strongly advised that you avoid emulation and buy a device instead. | |
"--device=/dev/kvm:/dev/kvm", | |
// This is needed for rendering the linux application. | |
"--device=/dev/dri:/dev/dri", | |
// This could probably be figured out with port mappings, but it makes life a lot easier, | |
// and I have not experienced any port collision scenarios yet. | |
"--network=host", | |
// Similarly, this makes life easier and the use case doesn't really need the security provided. | |
"--privileged", | |
// Increase /tmp shared memory size. Chrome will crash otherwise. | |
"--shm-size=4g", | |
// Mount the host's X11 socket directory. Needed to find the X server. | |
"--volume=/tmp/.X11-unix:/tmp/.X11-unix", | |
// If your host machine does not export this value. | |
// This allows the container's x11 client to authorize draw requests on the host's server. | |
"--volume=${localEnv:XAUTHORITY}:/home/vscode/.Xauthority", | |
// Needed for the linux application to connect to host user's dbus session. | |
"--volume=/run/user/1000/bus:/run/user/1000/bus" | |
], | |
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | |
"remoteUser": "vscode", | |
// Use 'postCreateCommand' to run commands after the container is created. | |
"postCreateCommand": "flutter pub get", | |
// Configure tool-specific properties. | |
"customizations": { | |
// Configure properties specific to VS Code. | |
"vscode": { | |
// Add the IDs of extensions you want installed when the container is created. | |
"extensions": [ | |
"dart-code.dart-code", | |
"dart-code.flutter", | |
"editorconfig.editorconfig" | |
] | |
} | |
} | |
} |
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
FROM opensuse/tumbleweed:latest | |
RUN set -ex && \ | |
rpm --import https://dl.google.com/linux/linux_signing_key.pub && \ | |
zypper addrepo http://dl.google.com/linux/chrome/rpm/stable/x86_64 google-chrome && \ | |
rpm --import https://packages.microsoft.com/keys/microsoft.asc && \ | |
zypper addrepo https://packages.microsoft.com/yumrepos/vscode vscode && \ | |
zypper refresh && \ | |
zypper install --no-confirm \ | |
binutils \ | |
clang \ | |
cmake \ | |
code \ | |
gcc \ | |
git \ | |
gtk3-devel \ | |
google-chrome-stable \ | |
iproute2 \ | |
java-11-openjdk-devel \ | |
jq \ | |
libopenssl-devel \ | |
libpulse0 \ | |
libXcomposite1 \ | |
man \ | |
man-pages \ | |
ninja \ | |
rsync \ | |
strace \ | |
system-group-kvm \ | |
sudo \ | |
unzip \ | |
vim \ | |
wget \ | |
xauth \ | |
xeyes \ | |
xhost \ | |
xorg-x11-server \ | |
xorg-x11-util-devel \ | |
xrdb \ | |
&& \ | |
zypper clean | |
ARG UID=1000 | |
ARG GID=100 | |
RUN set -ex && \ | |
useradd --uid ${UID} --gid ${GID} --groups kvm --create-home vscode && \ | |
echo 'vscode ALL=(root) NOPASSWD:ALL' > /etc/sudoers.d/vscode && \ | |
chmod 0440 /etc/sudoers.d/vscode | |
USER ${UID}:${GID} | |
WORKDIR /home/vscode | |
ENV JAVA_HOME=/usr/lib64/jvm/java-11-openjdk-11 | |
ENV KOTLIN_VERSION=1.7.10 | |
ARG KOTLIN_ARCHIVE=kotlin-compiler-${KOTLIN_VERSION}.zip | |
ARG KOTLIN_URL=https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/${KOTLIN_ARCHIVE} | |
ENV KOTLIN_HOME=/home/vscode/kotlinc | |
ENV PATH=${PATH}:${KOTLIN_HOME}/bin | |
RUN set -ex && \ | |
curl -sLO ${KOTLIN_URL} && \ | |
unzip ${KOTLIN_ARCHIVE} && \ | |
rm ${KOTLIN_ARCHIVE} && \ | |
kotlin -version && \ | |
kotlinc -version | |
ENV GRADLE_VERSION=7.5.1 | |
ARG GRADLE_DIST=bin | |
ARG GRADLE_ARCHIVE=gradle-${GRADLE_VERSION}-${GRADLE_DIST}.zip | |
ARG GRADLE_URL=https://services.gradle.org/distributions/${GRADLE_ARCHIVE} | |
ENV GRADLE_HOME=/home/vscode/gradle | |
ENV PATH=${PATH}:${GRADLE_HOME}/bin | |
RUN set -ex && \ | |
curl -sLO ${GRADLE_URL} && \ | |
unzip ${GRADLE_ARCHIVE} && \ | |
rm ${GRADLE_ARCHIVE} && \ | |
mv gradle-${GRADLE_VERSION} gradle && \ | |
gradle --version | |
ENV ANDROID_SDK_VERSION=9123335 | |
ARG ANDROID_SDK_ARCHIVE=commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip | |
ARG ANDROID_SDK_URL=https://dl.google.com/android/repository/${ANDROID_SDK_ARCHIVE} | |
ARG ANDROID_SDK_PACKAGES | |
ENV ANDROID_SDK_ROOT=/home/vscode/android-sdk | |
ENV PATH=${PATH}:${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin:${ANDROID_SDK_ROOT}/cmdline-tools/tools/bin:${ANDROID_SDK_ROOT}/platform-tools:${ANDROID_SDK_ROOT}/emulator | |
RUN set -ex && \ | |
mkdir -p ${ANDROID_SDK_ROOT}/cmdline-tools && \ | |
curl -sLO ${ANDROID_SDK_URL} && \ | |
unzip ${ANDROID_SDK_ARCHIVE} -d ${ANDROID_SDK_ROOT}/cmdline-tools && \ | |
rm ${ANDROID_SDK_ARCHIVE} && \ | |
mv ${ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools ${ANDROID_SDK_ROOT}/cmdline-tools/tools && \ | |
sdkmanager --version | |
COPY sdkmanager-accept-licenses.sh /usr/local/bin/sdkmanager-accept-licenses | |
RUN set -ex && \ | |
sudo chmod 555 /usr/local/bin/sdkmanager-accept-licenses && \ | |
/usr/local/bin/sdkmanager-accept-licenses && \ | |
sdkmanager 'cmdline-tools;latest' 'emulator' 'platform-tools' ${ANDROID_SDK_PACKAGES:-} && \ | |
/usr/local/bin/sdkmanager-accept-licenses | |
EXPOSE 5037 | |
ENV FLUTTER_VERSION=3.7.10 | |
ARG FLUTTER_DIST=stable | |
ARG FLUTTER_ARCHIVE=flutter_linux_${FLUTTER_VERSION}-${FLUTTER_DIST}.tar.xz | |
ARG FLUTTER_URL=https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_DIST}/linux/${FLUTTER_ARCHIVE} | |
ENV FLUTTER_HOME=/home/vscode/flutter | |
ENV PATH=${PATH}:${FLUTTER_HOME}/bin | |
RUN set -ex && \ | |
curl -sLO ${FLUTTER_URL} && \ | |
tar --extract --owner=${UID} --group=${GID} --file=${FLUTTER_ARCHIVE} && \ | |
rm ${FLUTTER_ARCHIVE} && \ | |
flutter --version && \ | |
flutter config --no-analytics && \ | |
flutter config --android-sdk $ANDROID_SDK_ROOT && \ | |
flutter precache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment