Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enabling java function dev experience in vscode + devcontainer #784

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Reference: https://github.com/devcontainers/images/blob/main/src/java/.devcontainer/Dockerfile
ARG TARGET_JAVA_VERSION=21
ARG BASE_IMAGE_VERSION_CODENAME=bookworm
FROM mcr.microsoft.com/devcontainers/base:${BASE_IMAGE_VERSION_CODENAME}

USER root
ARG TARGET_JAVA_VERSION
ENV JAVA_HOME /usr/lib/jvm/msopenjdk-current
ENV PATH "${JAVA_HOME}/bin:${PATH}"
# Default to UTF-8 file.encoding
ENV LANG en_US.UTF-8

# Install Microsoft OpenJDK
RUN arch="$(dpkg --print-architecture)" \
&& case "$arch" in \
"amd64") \
jdkUrl="https://aka.ms/download-jdk/microsoft-jdk-${TARGET_JAVA_VERSION}-linux-x64.tar.gz"; \
;; \
"arm64") \
jdkUrl="https://aka.ms/download-jdk/microsoft-jdk-${TARGET_JAVA_VERSION}-linux-aarch64.tar.gz"; \
;; \
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
esac \
\
&& wget --progress=dot:giga -O msopenjdk.tar.gz "${jdkUrl}" \
&& wget --progress=dot:giga -O sha256sum.txt "${jdkUrl}.sha256sum.txt" \
\
&& sha256sumText=$(cat sha256sum.txt) \
&& sha256=$(expr substr "${sha256sumText}" 1 64) \
&& echo "${sha256} msopenjdk.tar.gz" | sha256sum --strict --check - \
&& rm sha256sum.txt* \
\
&& mkdir -p "$JAVA_HOME" \
&& tar --extract \
--file msopenjdk.tar.gz \
--directory "$JAVA_HOME" \
--strip-components 1 \
--no-same-owner \
&& rm msopenjdk.tar.gz* \
\
&& ln -s ${JAVA_HOME} /docker-java-home \
&& ln -s ${JAVA_HOME} /usr/local/openjdk-${TARGET_JAVA_VERSION}

# [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>


# Install Maven
RUN apt-get update && apt-get install -y maven

# Install coretools package from linux software repository
RUN curl -sSL -O https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
&& apt-get update && apt-get install azure-functions-core-tools-4
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Azure Java Function Worker Development",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "none"
},
"ghcr.io/devcontainers/features/node:1": "none",
"ghcr.io/devcontainers/features/git:1": {
"version": "latest",
"ppa": "false"
}
},
"containerEnv": {
"JAVA_HOME": "/usr/lib/jvm/msopenjdk-current"
},
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack", // Java extension pack for VS Code
"vscjava.vscode-java-debug", // Java debug extension
"vscjava.vscode-maven", // Maven extension for VS Code
"ms-azuretools.vscode-azurefunctions", // Azure Functions extension
"ms-azuretools.vscode-azurestorage", // Azure Storage,
"Azurite.azurite" // Azurite extension
]
}
}
}