Skip to content

Commit

Permalink
devcontainer support
Browse files Browse the repository at this point in the history
  • Loading branch information
cthtrifork committed Feb 15, 2024
1 parent 9b80ebe commit 72d7d81
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG VARIANT=11-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/java:1-11-bullseye

ARG MAVEN_VERSION=""
RUN su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\"";
COPY --chown=vscode:vscode settings.xml /home/vscode/.m2/
COPY maven-settings.xml /usr/share/maven/ref/


# [Option] Install Gradle
ARG GRADLE_VERSION=""
RUN if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi


# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends git openssh-client less iproute2 procps curl lsb-release exa wget unzip

# 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

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
49 changes: 49 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 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.195.0/containers/java
{
"name": "Java",
"build": {
"dockerfile": "Dockerfile",
"args": {
"java.home": "/docker-java-home",
// Options
"MAVEN_VERSION": "3.6.3",
"INSTALL_GRADLE": "true",
"GRADLE_VERSION": "6.8.3"
}
},
"containerEnv": {
"GITHUB_ACTOR": "${localEnv:GITHUB_ACTOR}",
"GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}"
},
// Add the IDs of extensions you want installed when the container is created.
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack",
"DotJoshJohnson.xml",
"ms-azuretools.vscode-docker",
"VisualStudioExptTeam.vscodeintellicode",
"vscjava.vscode-maven",
"vscjava.vscode-java-dependency",
"redhat.vscode-yaml",
"tamasfe.even-better-toml",
"GitHub.copilot"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"java.home": "/docker-java-home",
"maven.executable.path": "/usr/local/sdkman/candidates/maven/current/bin/mvn"
}
}
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// 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"
}
6 changes: 6 additions & 0 deletions .devcontainer/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<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>
25 changes: 25 additions & 0 deletions .devcontainer/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- COPY OF ../settings.xml! -->
<settings>
<interactiveMode>false</interactiveMode>
<profiles/>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
<server>
<id>cheetah-lib-processing-local-dev-repo</id>
<configuration>
<timeout>6000</timeout> <!-- milliseconds -->
<httpConfiguration>
<all>
<connectionTimeout>5000</connectionTimeout>
<readTimeout>5000</readTimeout>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
<mirrors/>
</settings>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/build/
*/*.iml
./models/external/
bin/

# Compiled class file
*.class
Expand Down

0 comments on commit 72d7d81

Please sign in to comment.