Skip to content

Commit 5f6aa5c

Browse files
author
Ferenc Hammerl
committed
Add devcontainer config files and downgrade JDK
JDK 15 is very new, the dev container image is not updated with it yet!
1 parent b6f53b2 commit 5f6aa5c

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.137.0/containers/java/.devcontainer/base.Dockerfile
2+
ARG VARIANT="14"
3+
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
4+
5+
# [Optional] Install Maven or Gradle
6+
ARG INSTALL_MAVEN="false"
7+
ARG MAVEN_VERSION=3.6.3
8+
ARG INSTALL_GRADLE="false"
9+
ARG GRADLE_VERSION=5.4.1
10+
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
11+
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
12+
13+
# [Optional] Install a version of Node.js using nvm for front end dev
14+
ARG INSTALL_NODE="true"
15+
ARG NODE_VERSION="lts/*"
16+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
17+
18+
# [Optional] Uncomment this section to install additional OS packages.
19+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
20+
# && apt-get -y install --no-install-recommends <your-package-list-here>
21+
22+
# [Optional] Uncomment this line to install global node packages.
23+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "Java",
3+
"service": "app",
4+
5+
"workspaceFolder": "/workspace",
6+
7+
"dockerComposeFile": "docker-compose.yml",
8+
// Set *default* container specific settings.json values on container create.
9+
"settings": {
10+
"terminal.integrated.shell.linux": "/bin/bash",
11+
"java.home": "/docker-java-home",
12+
"maven.executable.path": "/usr/local/sdkman/candidates/maven/current/bin/mvn"
13+
},
14+
15+
// Add the IDs of extensions you want installed when the container is created.
16+
"extensions": [
17+
"vscjava.vscode-java-pack"
18+
],
19+
"forwardPorts": [8080],
20+
21+
// Use 'postCreateCommand' to run commands after the container is created.
22+
// "postCreateCommand": "java -version",
23+
24+
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
25+
"remoteUser": "vscode"
26+
}

.devcontainer/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
# This is where VS Code should expect to find your project's source code and the value of "workspaceFolder" in .devcontainer/devcontainer.json
10+
- ..:/workspace:cached
11+
# Overrides default command so things don't shut down after the process ends.
12+
command: /bin/sh -c "while sleep 1000; do :; done"
13+
network_mode: service:db
14+
db:
15+
image: "postgres"
16+
environment:
17+
POSTGRES_USER: postgres
18+
POSTGRES_PASSWORD: pwd1234
19+
POSTGRES_DB: doodle
20+
ports:
21+
- "5432:5432"
22+
volumes:
23+
- pg_db:/var/lib/postgresql/data
24+
25+
volumes:
26+
pg_db:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<description>Demo project for Spring Boot</description>
1616

1717
<properties>
18-
<java.version>15</java.version>
18+
<java.version>14</java.version>
1919
</properties>
2020

2121
<dependencies>

0 commit comments

Comments
 (0)