Skip to content

Commit a7d60f1

Browse files
feat: add devcontainers for enabling github codespaces usage. (#2605)
* feat: add devcontainers for enabling github codespaces usage. * fix: enable intallation of maven. * fix: add postCreateCommand script. * fix:upgrade to Java 11 to fix build errors in container builds. * chore: add 'clean' in the postCreate script. * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix: review comments. --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ac762fb commit a7d60f1

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

.devcontainer/Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Reference - https://github.com/microsoft/vscode-dev-containers/tree/main/containers/java-8/.devcontainer
2+
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
3+
# [Choice] Java version (use -bullseye variants on local arm64/Apple Silicon): 11, 17, 11-bullseye, 17-bullseye, 11-buster, 17-buster
4+
ARG VARIANT="bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/java:11-${VARIANT}
6+
7+
# [Option] Install Maven
8+
ARG INSTALL_MAVEN="true"
9+
ARG MAVEN_VERSION=""
10+
# [Option] Install Gradle
11+
ARG INSTALL_GRADLE="false"
12+
ARG GRADLE_VERSION=""
13+
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
14+
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
15+
16+
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
17+
ARG NODE_VERSION="lts/*"
18+
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
19+
20+
# install gloud sdk
21+
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-cli -y

.devcontainer/devcontainer.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "Java 11",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
7+
// Use bullseye when running on local arm64/Apple Silicon.
8+
"VARIANT": "bullseye",
9+
// Options
10+
"INSTALL_MAVEN": "true",
11+
"INSTALL_GRADLE": "false",
12+
"NODE_VERSION": "lts/*"
13+
}
14+
},
15+
16+
// Configure tool-specific properties.
17+
"customizations": {
18+
// Configure properties specific to VS Code.
19+
"vscode": {
20+
// Set *default* container specific settings.json values on container create.
21+
"settings": {
22+
"java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current",
23+
"java.configuration.runtimes": [{
24+
"default": true,
25+
"name": "JavaSE-11",
26+
"path": "/usr/local/sdkman/candidates/java/current"
27+
}]
28+
},
29+
30+
// Add the IDs of extensions you want installed when the container is created.
31+
"extensions": [
32+
"vscjava.vscode-java-pack",
33+
"ms-azuretools.vscode-docker"
34+
]
35+
}
36+
},
37+
38+
// Use 'postCreateCommand' to run commands after the container is created.
39+
"postCreateCommand": "bash .devcontainer/postCreate.sh",
40+
41+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
42+
"remoteUser": "vscode"
43+
}

.devcontainer/postCreate.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
echo "Post Create Starting"
2+
3+
mvn clean install -B -V -ntp \
4+
-DskipTests=true \
5+
-Dmaven.javadoc.skip=true \
6+
-Dclirr.skip=true

0 commit comments

Comments
 (0)