File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed
Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM mcr.microsoft.com/devcontainers/java:0-11
2+
3+ ARG INSTALL_MAVEN="false"
4+ ARG MAVEN_VERSION=""
5+
6+ ARG INSTALL_GRADLE="true"
7+ ARG GRADLE_VERSION=""
8+
9+ RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \" ${MAVEN_VERSION}\" " ; fi \
10+ && if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \" ${GRADLE_VERSION}\" " ; fi
11+
12+ # [Optional] Uncomment this section to install additional OS packages.
13+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
14+ # && apt-get -y install --no-install-recommends <your-package-list-here>
15+
16+ # [Optional] Uncomment this line to install global node packages.
17+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
Original file line number Diff line number Diff line change 1+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+ // README at: https://github.com/devcontainers/templates/tree/main/src/java-postgres
3+ {
4+ "name" : " Java & PostgreSQL" ,
5+ "dockerComposeFile" : " docker-compose.yml" ,
6+ "service" : " app" ,
7+ "workspaceFolder" : " /workspaces/${localWorkspaceFolderBasename}"
8+
9+ // Features to add to the dev container. More info: https://containers.dev/features.
10+ // "features": {}
11+
12+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
13+ // This can be used to network with other containers or with the host.
14+ // "forwardPorts": [5432],
15+
16+ // Use 'postCreateCommand' to run commands after the container is created.
17+ // "postCreateCommand": "java -version",
18+
19+ // Configure tool-specific properties.
20+ // "customizations": {},
21+
22+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
23+ // "remoteUser": "root"
24+ }
Original file line number Diff line number Diff line change 1+ version : ' 3.8'
2+
3+ volumes :
4+ postgres-data :
5+
6+ services :
7+ app :
8+ container_name : javadev
9+ build :
10+ context : .
11+ dockerfile : Dockerfile
12+ environment :
13+ # NOTE: POSTGRES_DB/USER/PASSWORD should match values in db container
14+ POSTGRES_PASSWORD : postgres
15+ POSTGRES_USER : postgres
16+ POSTGRES_DB : postgres
17+ POSTGRES_HOSTNAME : postgresdb
18+
19+ volumes :
20+ - ../..:/workspaces:cached
21+
22+ # Overrides default command so things don't shut down after the process ends.
23+ command : sleep infinity
24+
25+ # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
26+ network_mode : service:db
27+
28+ # Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
29+ # (Adding the "ports" property to this file will not forward from a Codespace.)
30+
31+ db :
32+ container_name : postgresdb
33+ image : postgres:latest
34+ restart : unless-stopped
35+ volumes :
36+ - postgres-data:/var/lib/postgresql/data
37+ environment :
38+ # NOTE: POSTGRES_DB/USER/PASSWORD should match values in app container
39+ POSTGRES_PASSWORD : postgres
40+ POSTGRES_USER : postgres
41+ POSTGRES_DB : postgres
42+
43+ # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
44+ # (Adding the "ports" property to this file will not forward from a Codespace.)
You can’t perform that action at this time.
0 commit comments