DEV Community

Cover image for My Ultimate Development Dockerfile
Tomer Figenblat
Tomer Figenblat

Posted on • Updated on

My Ultimate Development Dockerfile

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 | gpg --dearmor > microsoft.asc.gpg \
    && mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \
    && curl -sL \
        -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 \
    && 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 \
    && 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 | 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 \
    && 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 \ \ \ \ \ \ \
    # 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
Enter fullscreen mode Exit fullscreen mode

I hope you find this useful.

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

Top comments (0)