My Ultimate Development Dockerfile

tomerfi profile image Tomer Figenblat ・4 min read

My Ultimate Development Dockerfile

If you haven't heard of VSCode's Remote Development Feature yet...
Well frankly, I don't know what planet you live in...

Or maybe.. I'm the alien ❔

It's a feature that allows you to develop remotely from your workstation. Meaning, even though you writing code on your workstation, your whole environment is located elsewhere.

You can remotely develop on another station using SSH or WSL.
But my favorite feature is using Docker.
You can create a segregated isolated sandboxed environment for your whole development, or a specific project, inside a Docker Container.

Enough with the intro.
I've cultivated a Dockerfile I use throughout my projects. It's a pretty basic Dockerfile that installs my most frequently used binaries and tools.

The key here is the layers, they were pre-designed in a way so they can be sharable for all of my containers, and require little adaptation when modifying specific parts, basically:

  • Environment variables go at the lowest layer as they rarely get modified.

  • Binaries installations go in the next layers separately from one another, so when modified, they'll require only the layers above them to be rebuilt.

  • Modules, requirements, dependencies, packages, libraries, etc, go in the top layer as they get modified more frequently.

Enough with the chit-chat, here's my Ultimate Development Environment Dockerfile:

You can check out the actual Dockerfile in my Github Gist

# Base image is python's image
FROM python:3.8.5

# Set shell with pipeline fail return
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Set environment variables
ENV SHELL=/bin/bash \
    JAVA_HOME=/opt/java \
    MAVEN_HOME=/opt/maven \
    PATH_TO_FX=/usr/share/java/ \

# Install linux packages (including dotnet and javafx)
RUN curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg \
    && mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \
    && curl -sL https://packages.microsoft.com/config/debian/10/prod.list \
        -o /etc/apt/sources.list.d/microsoft-prod.list \
    && apt-get update \
    && apt-get install -y --no-install-recommends apt-transport-https \
    && apt-get install -y --no-install-recommends dotnet-sdk-3.1 \
    && apt-get install -y --no-install-recommends git-lfs \
    && apt-get install -y --no-install-recommends nano \
    && apt-get install -y --no-install-recommends openjfx \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install java
WORKDIR /opt/java
RUN curl -sOL https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10_openj9-0.20.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.7_10_openj9-0.20.0.tar.gz \
    && tar -xf OpenJDK11U-jdk_x64_linux_openj9_11.0.7_10_openj9-0.20.0.tar.gz \
    && rm OpenJDK11U-jdk_x64_linux_openj9_11.0.7_10_openj9-0.20.0.tar.gz \
    && mv jdk-11.0.7+10/* . \
    && rm -r jdk-11.0.7+10

# Install maven
WORKDIR /opt/maven
RUN curl -sOL https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz \
    && tar -xf apache-maven-3.6.3-bin.tar.gz \
    && rm apache-maven-3.6.3-bin.tar.gz \
    && mv apache-maven-3.6.3/* . \
    && rm -r apache-maven-3.6.3

# Install nodejs (includes npm)
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
    && apt-get install -y --no-install-recommends nodejs \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install golang
WORKDIR /opt/go
RUN curl -sOL https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz \
    && tar -C /opt -xf go1.14.4.linux-amd64.tar.gz \
    && rm go1.14.4.linux-amd64.tar.gz \
    && bin/go env -w GOPATH=/opt/gopath GO111MODULE=on

# Install modules, requirements, dependencies, packages, libraries, etc.
    # Install node modules
    npm install -g \
        commitizen@4.1.2 \
        cz-conventional-changelog@3.2.0 \
        @commitlint/cli@9.1.1 \
        @commitlint/config-conventional@9.1.1 \
        dockerfilelint@1.8.0 \
        jsonlint@1.6.3 \
        markdownlint-cli@0.23.2 \
        semantic-release@17.1.1 \
        yarn@1.22.4 \
    # Install go modules
    && go get -u \
        github.com/bufbuild/buf/cmd/buf@v0.20.5 \
        github.com/bufbuild/buf/cmd/protoc-gen-buf-check-breaking@v0.20.5 \
        github.com/bufbuild/buf/cmd/protoc-gen-buf-check-lint@v0.20.5 \
        github.com/client9/misspell/cmd/misspell@v0.3.4 \
        github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@v1.3.2 \
        github.com/yoheimuta/protolint/cmd/protolint@v0.26.0 \
    # Install python dependencies
    && pip install \
        docutils==0.16 \
        pre-commit==2.6.0 \
        robotframework==3.2.1 \
        yamllint==1.24.2 \
    # Install dotnet tools
    && dotnet tool install -g dotnet-format --version 4.1.131201 \
    && dotnet tool install -g dotnet-reportgenerator-globaltool --version 4.6.4

I hope you find this useful.

πŸ‘‹ See you in the next post πŸ‘‹

Posted on by:

tomerfi profile

Tomer Figenblat


I'm a software developer and a development ecosystem enthusiast... That means that if I'm not coding for work... 🀘 I'm coding for fun! 🀘


Editor guide