Skip to content

Instantly share code, notes, and snippets.

@juaoose
Created January 25, 2022 21:59
Show Gist options
  • Save juaoose/3a9c467da4b2d699a42c93050bf0bb57 to your computer and use it in GitHub Desktop.
Save juaoose/3a9c467da4b2d699a42c93050bf0bb57 to your computer and use it in GitHub Desktop.
devcontainer config for flutter development, based on https://gitlab.com/IvanTurgenev/flutter_vscode_remote
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/lucashilles/flutter-dev-container
{
"name": "Flutter",
"dockerFile": "Dockerfile",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"dart-code.dart-code",
"dart-code.flutter"
],
// This command create an example project after the container is created.
"postCreateCommand": "flutter create test_project",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
//"forwardPorts": [],
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
#-------------------------------------------------------------------------------------------------------------
# Flutter Dev Container - Lucas Hilleshein dos Santos.
# Licensed under the MIT License.
# See https://github.com/lucashilles/flutter-dev-container/blob/master/LICENSE for license information.
#-------------------------------------------------------------------------------------------------------------
FROM ubuntu:focal
#Locale
ENV LANG C.UTF-8
#
# Android SDK
# https://developer.android.com/studio#downloads
ENV ANDROID_SDK_TOOLS_VERSION 7583922
ENV ANDROID_PLATFORM_VERSION 29
ENV ANDROID_BUILD_TOOLS_VERSION 29.0.3
ENV ANDROID_HOME=/opt/android-sdk-linux
ENV ANDROID_SDK_ROOT="$ANDROID_HOME"
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/tools/bin:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/emulator
#
# Flutter SDK
# https://flutter.dev/docs/development/tools/sdk/releases?tab=linux
ENV FLUTTER_CHANNEL="stable"
ENV FLUTTER_VERSION="2.8.1"
# Set this variable as "enable" to auto config flutter web-server.
# Make sure to use the needed channel and version for this.
ENV FLUTTER_WEB="enable"
ENV FLUTTER_HOME=/opt/flutter
ENV PATH=${PATH}:${FLUTTER_HOME}/bin
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
#
# Install needed packages, setup user anda clean up.
RUN apt-get update \
&& apt-get install -y sudo \
&& apt-get install -y openjdk-11-jdk-headless --no-install-recommends \
&& apt-get install -y wget curl git xz-utils zip unzip --no-install-recommends \
# Clean Up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user.
# [Optional] Add sudo support for the non-root user
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
#
# Android SDK
RUN cd /opt \
&& curl -C - --output android-sdk-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip \
&& mkdir -p ${ANDROID_HOME}/cmdline-tools/ \
&& unzip -q android-sdk-tools.zip -d ${ANDROID_HOME}/cmdline-tools/ \
&& mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/tools \
&& rm android-sdk-tools.zip \
&& yes | sdkmanager --licenses \
&& touch $HOME/.android/repositories.cfg \
&& sdkmanager platform-tools \
&& sdkmanager emulator \
&& sdkmanager "platforms;android-$ANDROID_PLATFORM_VERSION" "build-tools;$ANDROID_BUILD_TOOLS_VERSION" \
&& sdkmanager --install "cmdline-tools;latest"
#
# Flutter SDK
RUN cd /opt \
&& curl -C - --output flutter.tar.xz https://storage.googleapis.com/flutter_infra_release/releases/${FLUTTER_CHANNEL}/linux/flutter_linux_${FLUTTER_VERSION}-${FLUTTER_CHANNEL}.tar.xz \
&& tar xf flutter.tar.xz -C . \
&& rm flutter.tar.xz \
&& yes | flutter doctor --android-licenses \
&& flutter config --no-analytics
@juaoose
Copy link
Author

juaoose commented Jan 27, 2022

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment