Skip to content

Commit

Permalink
Merge pull request #49 from rofrano/add-devcontainer
Browse files Browse the repository at this point in the history
Added devcontainer support for easy development environment setup
  • Loading branch information
rahlk authored Oct 21, 2024
2 parents d10d427 + e21d637 commit a58e716
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# FROM mcr.microsoft.com/devcontainers/java:1-21-bullseye
FROM ubuntu:22.04

# Add any tools that are needed beyond Java
RUN apt-get update && \
apt-get install -y sudo sed vim git make gcc zlib1g-dev zip unzip tree curl wget jq && \
apt-get autoremove -y && \
apt-get clean -y

# Create a user for development
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user with passwordless sudo privileges
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME -s /bin/bash \
&& usermod -aG sudo $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& chown -R $USERNAME:$USERNAME /home/$USERNAME

WORKDIR /codenet-minerva-code-analyzer

USER $USERNAME

# Install Java and Gradle via SDKMan
RUN curl -s "https://get.sdkman.io" | bash

# This SHELL command is needed to run using `source`
SHELL ["/bin/bash", "-c"]
RUN source "$HOME/.sdkman/bin/sdkman-init.sh" && \
sdk install java 17.0.12-sem && \
sdk use java 17.0.12-sem && \
sdk install gradle 8.9

44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// cspell: disable
{
"name": "CodeAnalyzer",
"dockerFile": "Dockerfile",
"context": "..",
"remoteUser": "vscode",
"workspaceFolder": "/codenet-minerva-code-analyzer",
"workspaceMount": "source=${localWorkspaceFolder},target=/codenet-minerva-code-analyzer,type=bind,consistency=delegated",
"runArgs": ["-h", "codenet"],
"customizations": {
"vscode": {
"settings": {
"markdown-preview-github-styles.colorTheme": "light",
"makefile.extensionOutputFolder": "/tmp",
"cSpell.words": [
"northstar",
"cyclomatic",
"jgrapht",
"stdlibs"
],
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true
}
},
"extensions": [
"vscjava.vscode-java-pack",
"vscjava.vscode-java-test",
"vscjava.vscode-java-debug",
"vscjava.vscode-gradle",
"donjayamanne.githistory",
"bierner.github-markdown-preview",
"yzhang.markdown-all-in-one",
"hnw.vscode-auto-open-markdown-preview",
"davidanson.vscode-markdownlint",
"bierner.markdown-preview-github-styles",
"streetsidesoftware.code-spell-checker",
"ms-azuretools.vscode-docker"
]
}
},
// Install the version of gradle the project uses
"postCreateCommand": "./gradlew"
}

0 comments on commit a58e716

Please sign in to comment.