Skip to content

Commit 1097c79

Browse files
authored
Add files via upload
1 parent aa1b10b commit 1097c79

File tree

3 files changed

+84
-10
lines changed

3 files changed

+84
-10
lines changed

Dockerfile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
FROM gradle:8-jdk17-alpine as stage-build
1+
FROM mcr.microsoft.com/devcontainers/java:1-21-bullseye
22

3-
WORKDIR /build
3+
ARG INSTALL_MAVEN="false"
4+
ARG MAVEN_VERSION=""
45

5-
COPY . /build/
6+
ARG INSTALL_GRADLE="true"
7+
ARG GRADLE_VERSION=""
68

7-
RUN gradle -x test build
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
811

9-
FROM amazoncorretto:17-alpine
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>
1015

11-
WORKDIR /app
12-
13-
COPY --from=stage-build /build/build/libs/ /app
14-
15-
ENTRYPOINT [ "java", "-jar", "file-tool-1.0-SNAPSHOT.jar" ]
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

devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
"jetbrains" : {
22+
"backend" : "IntelliJ"
23+
}
24+
},
25+
26+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
27+
// "remoteUser": "root"
28+
}

docker-compose.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.)

0 commit comments

Comments
 (0)