TL;DR
.devcontainer
must exist in the root folder of your code.
.devcontainer
├── Dockerfile
├── devcontainer.json
└── maven-settings.xml
- Place the files in this gist.
Additional
TL;DR
.devcontainer
must exist in the root folder of your code..devcontainer
├── Dockerfile
├── devcontainer.json
└── maven-settings.xml
Additional
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at: | |
// https://github.com/microsoft/vscode-dev-containers/tree/v0.128.0/containers/java-8 | |
{ | |
"name": "Java 8", | |
"dockerFile": "Dockerfile", | |
// Set *default* container specific settings.json values on container create. | |
"settings": { | |
"terminal.integrated.shell.linux": "/bin/bash", | |
"java.home": "/docker-java-home" | |
}, | |
// Add the IDs of extensions you want installed when the container is created. | |
"extensions": [ | |
"vscjava.vscode-java-pack" | |
], | |
// Use 'forwardPorts' to make a list of ports inside the container available locally. | |
"forwardPorts": [8080], | |
// Use 'postCreateCommand' to run commands after the container is created. | |
// "postCreateCommand": "java -version", | |
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. | |
"remoteUser": "vscode" | |
} |
#------------------------------------------------------------------------------------------------------------- | |
# Copyright (c) Microsoft Corporation. All rights reserved. | |
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. | |
#------------------------------------------------------------------------------------------------------------- | |
FROM openjdk:8-jdk | |
# 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 | |
# Configure apt | |
RUN apt-get update \ | |
&& export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ | |
# | |
# Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. | |
&& groupadd --gid $USER_GID $USERNAME \ | |
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ | |
# [Optional] Add sudo support for the non-root user | |
&& apt-get install -y sudo \ | |
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ | |
&& chmod 0440 /etc/sudoers.d/$USERNAME \ | |
# | |
# Verify git, needed tools installed | |
&& apt-get -y install git openssh-client less iproute2 procps curl lsb-release | |
#-------------------Uncomment the following steps to install Maven CLI Tools---------------------------------- | |
ARG MAVEN_VERSION=3.6.3 | |
ARG MAVEN_SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 | |
RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ | |
&& export DEBIAN_FRONTEND=noninteractive \ | |
&& curl -fsSL -o /tmp/apache-maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ | |
&& echo "${MAVEN_SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ | |
&& tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ | |
&& rm -f /tmp/apache-maven.tar.gz \ | |
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn | |
COPY maven-settings.xml /usr/share/maven/ref/ | |
ENV MAVEN_HOME /usr/share/maven | |
ENV MAVEN_CONFIG /root/.m2 | |
#------------------------------------------------------------------------------------------------------------- | |
#-------------------Uncomment the following steps to install Gradle CLI Tools--------------------------------- | |
# ENV GRADLE_HOME /opt/gradle | |
# ENV GRADLE_VERSION 5.4.1 | |
# ARG GRADLE_DOWNLOAD_SHA256=7bdbad1e4f54f13c8a78abc00c26d44dd8709d4aedb704d913fb1bb78ac025dc | |
# RUN curl -sSL --output gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \ | |
# && export DEBIAN_FRONTEND=noninteractive \ | |
# && echo "${GRADLE_DOWNLOAD_SHA256} *gradle.zip" | sha256sum --check - \ | |
# && unzip gradle.zip \ | |
# && rm gradle.zip \ | |
# && mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" \ | |
# && ln -s "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle | |
#------------------------------------------------------------------------------------------------------------- | |
# Clean up | |
RUN export DEBIAN_FRONTEND=noninteractive \ | |
&& apt-get autoremove -y \ | |
&& apt-get clean -y \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Allow for a consistant java home location for settings - image is changing over time | |
RUN if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi |
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | |
https://maven.apache.org/xsd/settings-1.0.0.xsd"> | |
<localRepository>/usr/share/maven/ref/repository</localRepository> | |
</settings> |