Skip to content

Commit 93bfc1c

Browse files
author
Ferenc Hammerl
committed
Added second docker-compose to root folder
Also created a build and run script - I ran out of time to set up a proper prod-like compose environment. Now we need maven installed and the main method selected in the pom.xml
1 parent 1547df4 commit 93bfc1c

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ ARG VARIANT="14"
33
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
44

55
# [Optional] Install Maven or Gradle
6-
ARG INSTALL_MAVEN="false"
6+
ARG INSTALL_MAVEN="true"
77
ARG MAVEN_VERSION=3.6.3
88
ARG INSTALL_GRADLE="false"
99
ARG GRADLE_VERSION=5.4.1
1010
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
1111
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
1212

1313
# [Optional] Install a version of Node.js using nvm for front end dev
14-
ARG INSTALL_NODE="true"
14+
ARG INSTALL_NODE="false"
1515
ARG NODE_VERSION="lts/*"
1616
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
1717

buildAndRun.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sleep 0.2 # So we log under db_1 :)
2+
echo "Hacky build-script is starting up. We're reusing the devcontainer (as opposed to getting a proper JRE image)"
3+
echo "This is going to take long the first time, Maven needs to install lots of dependencies"
4+
cd workspace
5+
/usr/local/sdkman/candidates/maven/current/bin/mvn -T 4 package -DskipTests -nsu -ntp
6+
cd target
7+
echo "Running spring application"
8+
java -jar polls-0.0.1-SNAPSHOT.jar

docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: .devcontainer/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 "/workspace/buildAndRun.sh"
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+
- 8080:8080 # for app
23+
volumes:
24+
- pg_db:/var/lib/postgresql/data
25+
- ./dbconfig/:/docker-entrypoint-initdb.d/
26+
27+
volumes:
28+
pg_db:

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
<properties>
1818
<java.version>14</java.version>
19+
<start-class>com.fhammerl.polls.PollsApplication</start-class>
1920
</properties>
21+
2022

2123
<dependencies>
2224
<dependency>

0 commit comments

Comments
 (0)