Skip to content

Commit 6cc9664

Browse files
chore(DVIZ-24): add initial docker configuration, add compose config to test the docker build
1 parent 03a6a05 commit 6cc9664

File tree

7 files changed

+179
-47
lines changed

7 files changed

+179
-47
lines changed

.dockerignore

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.factorypath
12+
**/.git
13+
**/.gitignore
14+
**/.idea
15+
**/.project
16+
**/.sts4-cache
17+
**/.settings
18+
**/.toolstarget
19+
**/.vs
20+
**/.vscode
21+
**/.next
22+
**/.cache
23+
**/*.dbmdl
24+
**/*.jfm
25+
**/docker-compose*
26+
**/compose.y*ml
27+
**/Dockerfile*
28+
**/secrets.dev.yaml
29+
**/values.dev.yaml
30+
**/vendor
31+
LICENSE
32+
ui/readme.md
33+
**/*.class
34+
**/*.iml
35+
**/*.ipr
36+
**/*.iws
37+
**/*.log
38+
**/.apt_generated
39+
**/.gradle
40+
**/.gradletasknamecache
41+
**/.nb-gradle
42+
**/.springBeans
43+
**/build
44+
**/dist
45+
**/gradle-app.setting
46+
**/nbbuild
47+
**/nbdist
48+
**/nbproject/private
49+
**/target
50+
*.ctxt
51+
.mtj.tmp
52+
.mvn/timing.properties
53+
buildNumber.properties
54+
dependency-reduced-pom.xml
55+
hs_err_pid*
56+
pom.xml.next
57+
pom.xml.releaseBackup
58+
pom.xml.tag
59+
pom.xml.versionsBackup
60+
release.properties
61+
replay_pid*

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ npm-debug.log
1313
rebel.xml
1414
/logs/
1515
/LOG_DIR_IS_UNDEFINED
16-
/derby.log
16+
/derby.log
17+
18+
.env
19+
!.env.example

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM maven:3-amazoncorretto-21 AS base
2+
3+
FROM base AS builder
4+
WORKDIR /app
5+
6+
COPY . /app
7+
# Use cache mounts so dependencies aren't re-downloaded on every build
8+
RUN --mount=type=cache,target=/root/.m2 mvn -B clean install -DskipTests -Dcheckstyle.skip
9+
10+
# Create directory for extracting the JAR
11+
RUN mkdir -p forms/target/deps
12+
13+
# Extract the JAR contents
14+
FROM builder AS assembler
15+
WORKDIR /app/forms/target/deps
16+
RUN jar -xf ../*.jar
17+
18+
# Build the runtime image
19+
FROM openjdk:21-jdk-slim AS runtime
20+
WORKDIR /opt/devgateway/tcdi/admin
21+
22+
# Copy the application code
23+
COPY --from=assembler /app/forms/target/deps ./deps
24+
25+
# Copy entrypoint script
26+
COPY entrypoint.sh ./
27+
EXPOSE 8080
28+
RUN chmod +x entrypoint.sh
29+
ENTRYPOINT ["/opt/devgateway/tcdi/admin/entrypoint.sh"]
30+
CMD ["admin"]

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
web:
3+
image: data-viz-admin:latest
4+
environment:
5+
SPRING_DATASOURCE_JDBC_URL: "jdbc:postgresql://postgres:5432/tcdi_admin"
6+
SPRING_JPA_HIBERNATE_DDL-AUTO: "update"
7+
SPRING_DATASOURCE_USERNAME: "postgres"
8+
SPRING_DATASOURCE_PASSWORD: "admin"
9+
SERVER_PORT: 8083
10+
networks:
11+
- backend
12+
depends_on:
13+
- postgres
14+
15+
16+
postgres:
17+
image: mdillon/postgis
18+
restart: unless-stopped
19+
volumes:
20+
- postgres_data:/var/lib/postgresql/data
21+
environment:
22+
POSTGRES_PASSWORD: admin
23+
POSTGRES_USER: postgres
24+
POSTGRES_DB: tcdi_admin
25+
healthcheck:
26+
test: [ "CMD-SHELL", "pg_isready -Upostgres", "-d", "postgres" ]
27+
interval: 10s
28+
timeout: 30s
29+
retries: 3
30+
start_period: 50s
31+
networks:
32+
backend:
33+
34+
35+
networks:
36+
backend:
37+
38+
volumes:
39+
postgres_data:

entrypoint.sh

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3+
PROP_FILE="/etc/$1.properties"
4+
truncate -s 0 $PROP_FILE
5+
echo "..................... Writing to $PROP_FILE: ............... "
36

4-
PROP_FILE="tcdi-admin.properties"
5-
echo "Writing to $PROP_FILE:"
7+
while IFS='=' read -r -d '' n v; do
8+
if [[ $n == SPRING* ]]; then
9+
VAR_NAME="$(echo "$n" | tr '[:upper:]_' '[:lower:].')"
10+
echo "$VAR_NAME=$v" >> $PROP_FILE
11+
fi
12+
done < <(env -0)
613

7-
PROPERTIES="$(cat <<-EOF
8-
server.port
9-
spring.application.name
10-
spring.liquibase.enabled
11-
spring.datasource.jdbc-url
12-
spring.datasource.url
13-
spring.mail.host
14-
spring.jpa.hibernate.ddl-auto
15-
EOF
16-
)"
14+
while IFS='=' read -r -d '' n v; do
15+
if [[ $n == TCDI_* ]]; then
16+
VAR_NAME="$(echo "$n" | tr '[:upper:]_' '[:lower:].' | cut -c 6-)"
17+
echo "$VAR_NAME=$v" >> $PROP_FILE
18+
fi
19+
done < <(env -0)
1720

18-
env
21+
echo "................. Properties ................."
22+
cat $PROP_FILE
23+
echo "................. End Properties ................."
1924

20-
echo "$PROPERTIES" | while IFS=read PROPERTY; do
21-
VAR_NAME="$(echo "$PROPERTY" | tr '[:lower:].-' '[:upper:]__')"
22-
eval VALUE="\$$VAR_NAME"
23-
if [ -n "$VALUE" ]; then
24-
echo "$PROPERTY=$VALUE"
25-
fi
26-
done | tee -a "$PROP_FILE"
25+
# Set up correct classpath to include all dependencies
26+
JAVA_OPTS="-Dspring.config.location=file://$PROP_FILE"
27+
28+
# Run the application with the correct classpath
29+
cd /opt/devgateway/tcdi/admin/deps
30+
exec java -cp .:BOOT-INF/classes:BOOT-INF/lib/* org.devgateway.toolkit.forms.wicket.FormsWebApplication $JAVA_OPTS $@
2731

28-
JAR="tcdi-admin-forms-0.0.1-SNAPSHOT.jar"
29-
JAVA_OPTS="-Dspring.config.location=file://$PROP_FILE"
30-
#exec /bin/sh -c "java -jar '$JAR' $JAVA_OPTS $@" nobody
31-
exec /bin/bash
32-
;;
33-
*)
34-
exec $@
35-
;;

forms/pom.xml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -370,27 +370,30 @@
370370
<include>**/*.gif</include>
371371
<include>**/*.html</include>
372372
<include>**/*.properties</include>
373+
<include>**/*.class</include>
373374
</includes>
374375
</resource>
375376
</resources>
376-
377+
378+
<sourceDirectory>src/main/java</sourceDirectory>
379+
377380
<plugins>
378381

379-
<plugin>
380-
<groupId>pl.project13.maven</groupId>
381-
<artifactId>git-commit-id-plugin</artifactId>
382-
<version>2.2.4</version>
383-
<executions>
384-
<execution>
385-
<goals>
386-
<goal>revision</goal>
387-
</goals>
388-
</execution>
389-
</executions>
390-
<configuration>
391-
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
392-
</configuration>
393-
</plugin>
382+
<!-- <plugin>-->
383+
<!-- <groupId>pl.project13.maven</groupId>-->
384+
<!-- <artifactId>git-commit-id-plugin</artifactId>-->
385+
<!-- <version>2.2.4</version>-->
386+
<!-- <executions>-->
387+
<!-- <execution>-->
388+
<!-- <goals>-->
389+
<!-- <goal>revision</goal>-->
390+
<!-- </goals>-->
391+
<!-- </execution>-->
392+
<!-- </executions>-->
393+
<!-- <configuration>-->
394+
<!-- <dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>-->
395+
<!-- </configuration>-->
396+
<!-- </plugin>-->
394397

395398
<!-- tag::plugin[] -->
396399
<plugin>

forms/src/main/java/org/devgateway/toolkit/forms/wicket/page/lists/AbstractListPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void populateItem(final Item<ICellPopulator<T>> cellItem, final String co
175175
}
176176

177177
private Integer getPageSize() {
178-
return adminSettingsService.get().getPageSize();
178+
return adminSettingsService.get() != null ? adminSettingsService.get().getPageSize() : 10;
179179
}
180180

181181
protected PageParameters getEditPageParameters() {

0 commit comments

Comments
 (0)