Skip to content

Commit

Permalink
Update dev container to use Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
mwodahl committed May 30, 2024
1 parent 8bf4e57 commit 1cc54d0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 68 deletions.
44 changes: 23 additions & 21 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.217.4/containers/java/.devcontainer/base.Dockerfile
# Install openJDK version 21 (includes maven, gradle, and node)
FROM cimg/openjdk:21.0.2-node

# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
ARG VARIANT="17"
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
# set user to root to allow apt-get to run
USER root

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

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; 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 <your-package-list-here>
# Create non-root user vscode with sudo support
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
#
# 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 \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME

# [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
# RUN npm install -g <your-package-list-here>

# install kafkacat for testing purposes
RUN apt-get update && apt-get install -y kafkacat
RUN apt-get update && apt-get install -y kafkacat

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
21 changes: 5 additions & 16 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,18 @@
{
"name": "Java",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update the VARIANT arg to pick a Java version: 11, 17
// Append -bullseye or -buster to pin to an OS version.
// Use the -bullseye variants on local arm64/Apple Silicon.
"VARIANT": "11",
// Options
"INSTALL_MAVEN": "true",
"INSTALL_GRADLE": "false",
"NODE_VERSION": "none"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"java.home": "/docker-java-home"
"dockerfile": "Dockerfile"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vscjava.vscode-java-pack"
],

"containerEnv": {
"SHELL": "/bin/bash"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

Expand Down
33 changes: 2 additions & 31 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,11 @@
"configurations": [
{
"type": "java",
"name": "S3D Local",
"name": "S3D",
"request": "launch",
"mainClass": "us.dot.its.jpo.ode.aws.depositor.AwsDepositor",
"projectName": "jpo-aws-depositor",
"args": ["--bootstrap-server", "<kafka host>:9092",
"-d", "s3",
"-g", "testgroup",
"-k", "testkey",
"-b", "s3dtestbucket",
"-t", "test"],
"env": {
"AWS_ACCESS_KEY_ID": "<access key id>",
"AWS_SECRET_KEY": "<access secret key>"
}
},
{
"type": "java",
"name": "S3D CC",
"request": "launch",
"mainClass": "us.dot.its.jpo.ode.aws.depositor.AwsDepositor",
"projectName": "jpo-aws-depositor",
"args": ["--bootstrap-server", "<kafka host host>:9092",
"-g", "testgroup",
"-t", "topic.OdeBsmJson",
"-b", "s3dtestbucket",
"-k", "testkey",
"-d", "s3"],
"env": {
"AWS_ACCESS_KEY_ID": "<access key id>",
"AWS_SECRET_KEY": "<access secret key>",
"KAFKA_TYPE": "CONFLUENT",
"CONFLUENT_KEY": "<confluent key>",
"CONFLUENT_SECRET": "<confluent secret>"
}
"envFile": "${workspaceFolder}/.env",
}
]
}

0 comments on commit 1cc54d0

Please sign in to comment.