Skip to content

Commit 7c4056a

Browse files
authored
Liquibase content (#40)
1 parent f96b8bd commit 7c4056a

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

.docker/application.properties.tpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
1414
spring.jpa.properties.hibernate.show_sql=true
1515
spring.jpa.properties.hibernate.format_sql=true
1616
spring.jpa.properties.hibernate.use_sql_comments=true
17-
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
17+
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
18+
spring.liquibase.enabled={{default .Env.PATTERN_ATLAS_FETCH_INITIAL_DATA "false"}}

.docker/copy_initial_data.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
mkdir /tmp/pattern-atlas-content
4+
git clone --single-branch --branch ${PATTERN_ATLAS_CONTENT_REPOSITORY_BRANCH} ${PATTERN_ATLAS_CONTENT_REPOSITORY_URL} /tmp/pattern-atlas-content
5+
6+
cp /tmp/pattern-atlas-content/liquibase_changelog/*.xml /var/www/java/
7+
8+
if [ "$PATTERN_ATLAS_FETCH_INITIAL_DATA" = "true" ]
9+
then
10+
rm /var/www/java/patternatlas.xml
11+
mv /var/www/java/patternatlas_full.xml /var/www/java/patternatlas.xml
12+
fi

Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,25 @@ RUN mvn package -DskipTests
66
RUN mv target/patternatlas.api-1.2.0-SNAPSHOT.jar target/patternatlas.api-1.2.0-SNAPSHOT-no-hal-explorer.jar
77
RUN mvn package -DskipTests -PHAL_EXPLORER
88

9-
109
FROM openjdk:8
1110

1211
ARG DOCKERIZE_VERSION=v0.6.1
1312

13+
#liquibase initial data
14+
ENV PATTERN_ATLAS_FETCH_INITIAL_DATA false
15+
ENV PATTERN_ATLAS_CONTENT_REPOSITORY_URL "https://github.com/PatternAtlas/pattern-atlas-content.git"
16+
ENV PATTERN_ATLAS_PRIVATE_CONTENT_REPOSITORY_URL "[email protected]:PatternAtlas/internal-pattern-atlas-content.git"
17+
ENV PATTERN_ATLAS_CONTENT_REPOSITORY_BRANCH "main"
18+
19+
# install dependencies (git)
20+
RUN apt-get update \
21+
&& apt-get update -qq && apt-get install -qqy \
22+
git \
23+
&& apt-get clean \
24+
&& rm -rf /var/lib/apt/lists/*
25+
1426
ENV API_PORT 1977
15-
ENV JDBC_DATABASE_URL localhost
27+
ENV JDBC_DATABASE_URL host.docker.internal
1628
ENV JDBC_DATABASE_USERNAME postgres
1729
ENV JDBC_DATABASE_PASSWORD postgres
1830
ENV JDBC_DATABASE_NAME postgres
@@ -29,7 +41,11 @@ COPY --from=builder /tmp/pattern-atlas-api/target/patternatlas.api-1.2.0-SNAPSHO
2941

3042
ADD .docker/application.properties.tpl /var/www/java/application.properties.tpl
3143

44+
ADD .docker/copy_initial_data.sh /var/www/java/copy_initial_data.sh
45+
3246
CMD dockerize -template /var/www/java/application.properties.tpl:/var/www/java/application.properties \
47+
&& chmod +x /var/www/java/copy_initial_data.sh \
48+
&& /var/www/java/copy_initial_data.sh \
3349
&& cd /var/www/java/ \
3450
&& if [ "$HAL_EXPLORER" = "true" ]; then java -jar api.jar; else java -jar api_no_hal_explorer.jar; fi
3551

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@
105105
<scope>runtime</scope>
106106
</dependency>
107107

108+
<!-- Liquibase migration -->
109+
<dependency>
110+
<groupId>org.liquibase</groupId>
111+
<artifactId>liquibase-core</artifactId>
112+
<version>4.8.0</version>
113+
</dependency>
114+
108115
<!-- Apache Commons (String Library) -->
109116

110117
<dependency>

src/main/resources/application.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ io.github.patternatlas.api.latexrenderer.hostname=localhost
2323
io.github.patternatlas.api.latexrenderer.port=5030
2424
# Embedded Tomcat
2525
server.servlet.contextPath=/patternatlas
26+
# liquibase file
27+
spring.liquibase.change-log=file:patternatlas.xml

0 commit comments

Comments
 (0)