Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 03faa53

Browse files
authored
Merge pull request #17 from testforstephen/jinbo_javaFunctions
Add java azure-functions container definition
2 parents d30dbda + 93bf76a commit 03faa53

File tree

20 files changed

+682
-0
lines changed

20 files changed

+682
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#-----------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See LICENSE in the project root for license information.
4+
#-----------------------------------------------------------------------------------------
5+
6+
FROM maven:3-jdk-8
7+
8+
# Configure apt
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
RUN apt-get update \
11+
&& apt-get -y install --no-install-recommends apt-utils 2>&1
12+
13+
# Install dotnet core sdk - See https://github.com/dotnet/dotnet-docker/blob/master/2.1/sdk/stretch/amd64/Dockerfile
14+
# Install .NET CLI dependencies
15+
RUN apt-get install -y --no-install-recommends \
16+
libc6 \
17+
libgcc1 \
18+
libgssapi-krb5-2 \
19+
libicu57 \
20+
liblttng-ust0 \
21+
libssl1.0.2 \
22+
libstdc++6 \
23+
zlib1g
24+
25+
# Install .NET Core SDK
26+
ENV DOTNET_SDK_VERSION 2.1.603
27+
28+
RUN curl -SL --output dotnet.tar.gz https://dotnetcli.blob.core.windows.net/dotnet/Sdk/$DOTNET_SDK_VERSION/dotnet-sdk-$DOTNET_SDK_VERSION-linux-x64.tar.gz \
29+
&& dotnet_sha512='dd0efb8aae75d8f48ef3abbeca38ae14d2621a47e37b2d9d74755b58f9173343305f1a62cfa9a03f17c42f58b1d1b653d271e7d1327c81ff4af0a54c43c7db59' \
30+
&& echo "$dotnet_sha512 dotnet.tar.gz" | sha512sum -c - \
31+
&& mkdir -p /usr/share/dotnet \
32+
&& tar -zxf dotnet.tar.gz -C /usr/share/dotnet \
33+
&& rm dotnet.tar.gz \
34+
&& ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
35+
36+
# Configure web servers to bind to port 80 when present
37+
ENV ASPNETCORE_URLS=http://+:80 \
38+
# Enable detection of running in a container
39+
DOTNET_RUNNING_IN_CONTAINER=true \
40+
# Enable correct mode for dotnet watch (only mode supported in a container)
41+
DOTNET_USE_POLLING_FILE_WATCHER=true \
42+
# Skip extraction of XML docs - generally not useful within an image/container - helps performance
43+
NUGET_XMLDOC_MODE=skip
44+
45+
# Trigger first run experience by running arbitrary cmd to populate local package cache
46+
RUN dotnet help &> /dev/null
47+
48+
# Verify git and needed tools are installed
49+
RUN apt-get -y install \
50+
git \
51+
procps \
52+
curl \
53+
apt-transport-https \
54+
gnupg2 \
55+
lsb-release
56+
57+
# Install Azure Functions and Azure CLI
58+
RUN echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/azure-cli.list \
59+
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-$(lsb_release -cs)-prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list \
60+
&& curl -sL https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 2>/dev/null \
61+
&& apt-get update \
62+
&& apt-get install -y azure-cli azure-functions-core-tools
63+
64+
# Clean up
65+
RUN apt-get autoremove -y \
66+
&& apt-get clean -y \
67+
&& rm -rf /var/lib/apt/lists/*
68+
ENV DEBIAN_FRONTEND=dialog
69+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "Azure Functions & Java 8",
3+
"dockerFile": "Dockerfile",
4+
"appPort": 7071,
5+
"extensions": [
6+
"ms-azuretools.vscode-azurefunctions",
7+
"vscjava.vscode-java-pack",
8+
"redhat.vscode-xml"
9+
]
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
README.md
2+
test-project
3+
.vscode
4+
.npmignore
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions",
4+
"vscjava.vscode-java-debug"
5+
]
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Java Functions",
6+
"type": "java",
7+
"request": "attach",
8+
"hostName": "127.0.0.1",
9+
"port": 5005,
10+
"preLaunchTask": "func: host start"
11+
}
12+
]
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"azureFunctions.projectRuntime": "~2",
3+
"azureFunctions.projectLanguage": "Java",
4+
"azureFunctions.deploySubpath": "target/azure-functions/myapp-20190424131606275/",
5+
"azureFunctions.preDeployTask": "package",
6+
"debug.internalConsoleOptions": "neverOpen"
7+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"command": "host start",
7+
"problemMatcher": "$func-watch",
8+
"isBackground": true,
9+
"options": {
10+
"cwd": "${workspaceFolder}/test-project/target/azure-functions/myapp-20190424131606275/"
11+
},
12+
"dependsOn": "package"
13+
},
14+
{
15+
"label": "package",
16+
"command": "cd ${workspaceFolder}/test-project && mvn clean package",
17+
"type": "shell"
18+
}
19+
]
20+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Azure Functions & Java 8
2+
3+
## Summary
4+
5+
*Develop Azure Functions in Java. Includes JDK 8, Maven, XML tools, the Azure Functions SDK, and related extensions and dependencies.*
6+
7+
| Metadata | Value |
8+
|----------|-------|
9+
| *Contributors* | The VS Code Java Team |
10+
| *Definition type* | Dockerfile |
11+
| *Languages, platforms* | Azure Functions, Java |
12+
13+
## Using this definition with an existing folder
14+
15+
This definition requires an Azure subscription to use. You can create a [free account here](https://azure.microsoft.com/en-us/free/serverless/), learn more about using [Azure Functions with VS Code](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-vs-code) and [Java Azure Functions with VS Code](https://code.visualstudio.com/docs/java/java-azurefunctions) here. Once you have an Azure account, follow these steps:
16+
17+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
18+
19+
2. To use VS Code's copy of this definition:
20+
1. Start VS Code and open your project folder.
21+
2. Press <kbd>F1</kbd> select and **Remote-Containers: Create Container Configuration File...** from the command palette.
22+
3. Select the Azure Functions & Java 8 definition.
23+
24+
3. To use latest-and-greatest copy of this definition from the repository:
25+
1. Clone this repository.
26+
2. Copy the contents of `containers/azure-functions-java-8/.devcontainer` to the root of your project folder.
27+
3. Start VS Code and open your project folder.
28+
29+
4. After following step 2 or 3, the contents of the `.devcontainer` folder in your project can be adapted to meet your needs.
30+
31+
5. Finally, press <kbd>F1</kbd> and run **Remote-Containers: Reopen Folder in Container** to start using the definition.
32+
33+
## Testing the definition
34+
35+
This definition includes some test code that will help you verify it is working as expected on your system. Follow these steps:
36+
37+
1. If this is your first time using a development container, please follow the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started) to set up your machine.
38+
2. Clone this repository.
39+
3. Start VS Code, press <kbd>F1</kbd>, and select **Remote-Containers: Open Folder in Container...**
40+
4. Select the `containers/azure-functions-java-8` folder.
41+
5. After the folder has opened in the container, press <kbd>F5</kbd> to start the project.
42+
6. After the debugger is started, type `curl http://localhost:7071/api/HttpTrigger-Java?name=test` in the terminal, you should see "Hello, test" echoed by the Azure Function.
43+
7. From here, you can add breakpoints or edit the contents of the `test-project` folder to do further testing.
44+
45+
## License
46+
47+
Copyright (c) Microsoft Corporation. All rights reserved.
48+
49+
Licensed under the MIT License. See [LICENSE](https://github.com/Microsoft/vscode-dev-containers/blob/master/LICENSE).
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="src" path="target/generated-sources/annotations">
27+
<attributes>
28+
<attribute name="optional" value="true"/>
29+
<attribute name="maven.pomderived" value="true"/>
30+
<attribute name="ignore_optional_problems" value="true"/>
31+
<attribute name="m2e-apt" value="true"/>
32+
</attributes>
33+
</classpathentry>
34+
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
35+
<attributes>
36+
<attribute name="optional" value="true"/>
37+
<attribute name="maven.pomderived" value="true"/>
38+
<attribute name="ignore_optional_problems" value="true"/>
39+
<attribute name="m2e-apt" value="true"/>
40+
<attribute name="test" value="true"/>
41+
</attributes>
42+
</classpathentry>
43+
<classpathentry kind="output" path="target/classes"/>
44+
</classpath>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Build output
2+
target/
3+
*.class
4+
5+
# Log file
6+
*.log
7+
8+
# BlueJ files
9+
*.ctxt
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
*.jar
16+
*.war
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
25+
# IDE
26+
.idea/
27+
*.iml
28+
29+
# macOS
30+
.DS_Store
31+
32+
# Azure Functions
33+
local.settings.json
34+
bin/
35+
obj/

0 commit comments

Comments
 (0)