Docker on the Educative Platform

We use Docker to allow authors to create their own custom environments to accommodate any language that is not supported by our platform.

Authors can create custom docker images that deploy on the Google Cloud and allow end-users to directly have access to these customized environments through our platform.

The Jargon

Base Image: An OS userspace.

Image: A read-only template with instructions for creating a Docker container.

Dockerfile: A simple file with no extension, named Dockerfile is used to builds a Docker image, and specifies everything that will go in the application’s environment setup.

Container: An image when run, builds a container. This contains your application environment, basically where your application will be run.

Tarball

Press + to interact
-tarball
--Dockerfile

The above shows the directory structure of our tarball.

The command to create this tarball is as follows:

Press + to interact
tar -czpf flutter.tar.gz Dockerfile

As you can see, the Dockerfile must be nested directly inside the tarball (not inside any child folder).

This allows Educative to access the Dockerfile directly and create a docker container for our application’s environment.

Points to Note:

  • All files can be found for download in the Appendix of this lesson.
  • Only ONE tarball can be uploaded and used at a time. Uploading a new tarball will replace any previously uploaded.

Dockerfile

Press + to interact
FROM gcr.io/educative-exec-env/android-v2
RUN flutter channel stable && flutter upgrade --force

Line 1: FROM gcr.io/educative-exec-env/android-v2 :

The FROM command sets the Base Image for the rest of the instructions. This command must be on top of the Dockerfile.

In this example, we are starting with the base image of android-v2. This will allow us to install Android Version 2 from the educative-exec-env from Educative Hub gcr.io. Make sure you use android-v2 version in your Dockerfile if you are making an Android App

Line 2: RUN flutter channel stable && flutter upgrade --force

The RUN command is used to execute instructions against the image. It is used to run a command during the build process of the docker image.

We are selecting the stable channel as it gets selected by default on running flutter channel. Then we are upgrading flutter using the flutter upgrade command to resolve issues of dependencies and upgrading flutter to the latest 2.10.

Uploading the tarball

Overview of Docker container options on platform
Overview of Docker container options on platform

Once you start uploading, the changes will only be visible once you save the course, so press SAVE.

Dockerfile is uploading
Dockerfile is uploading

Image is being built
Image is being built

Image has been built
Image has been built

Docker Job

Create a new docker job by selecting Docker Job Type Android, name it in Job Name, Check the Run APK checkbox and add cache Path /usercode as it is the default directory for Android widget.

Docker Job
Docker Job

Version Specification

In case you want a specific version of Flutter, use the following commands in the Dockerfile.

Press + to interact
cd "$(dirname $(which flutter))"
git checkout v1.5.2
flutter version v1.5.2

Line 1: cd "$(dirname $(which flutter))"

Takes us to the path where flutter is installed, typically to root@educative:/opt/flutter/bin

Line 2: git checkout v1.5.2

Checks out v1.5.2 and takes you to the detached Head state of the git.

Line 3: flutter version v1.5.2

Downloads the specified flutter version.

Note: Makes changes after v in the file to specify your version. You can write any available version of flutter after v.

Appendix

File to download

The file attached below can be used to set the environment on Educative’s Platform.

flutter.tar.gz