Skip to content

Commit 000cdf9

Browse files
committed
Add a Docker Image build
1 parent fa363f6 commit 000cdf9

3 files changed

Lines changed: 205 additions & 0 deletions

File tree

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,37 @@ Learn how to customize the application.
4545

4646
### Developing this Code Base
4747
You can run the integration tests by executing `./mvnw clean package -Pintegration-test`.
48+
49+
#### Docker Image
50+
The Srophe application can also be compiled into a Docker Image where its EXPath Package is already deployed to Elemental.
51+
52+
If you would like to build the Docker Image, you simply need to make sure you have Docker installed,
53+
and then include the build argument `-Pdocker`, for example:
54+
55+
##### macOS / Linux / Unix Platforms
56+
Run the following from a Terminal/Shell:
57+
58+
```shell
59+
./mvnw -Pdocker clean package
60+
```
61+
62+
##### Microsoft Windows Platforms
63+
Run the following from a Command Prompt:
64+
```cmd
65+
mvnw.cmd -Pdocker clean package
66+
```
67+
68+
#### Running Srophe with Docker
69+
You should first create a Docker Volume to hold your Elemental database files. You need do this only once:
70+
```shell
71+
docker volume create srophe-database
72+
```
73+
74+
Once you have built (or obtained) the Docker Image, you can run Srophe in Docker like so:
75+
76+
```shell
77+
docker run -it -p 8080:8080 --mount type=volume,src=srophe-database,dst=/elemental/data srophe/srophe:latest
78+
```
79+
80+
Srophe will then be available in your web-browser at `http://localhost:8080/exist/apps/srophe/index.html`
81+
**NOTE**: The first time you use the Docker Image, you will need to deploy data for Srophe to use!

pom.xml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,153 @@
432432
</plugins>
433433
</build>
434434
</profile>
435+
436+
<profile>
437+
<!-- NOTE(AR) Profile to build a Docker Image -->
438+
<id>docker</id>
439+
<properties>
440+
<!-- directory that contains the filtered Dockerfile -->
441+
<docker.dir>${project.build.directory}/docker</docker.dir>
442+
<!-- directory for placing files that will be added to the Docker Image -->
443+
<docker.context.dir>${project.build.directory}/docker-context</docker.context.dir>
444+
</properties>
445+
<build>
446+
<plugins>
447+
<plugin>
448+
<groupId>org.apache.maven.plugins</groupId>
449+
<artifactId>maven-resources-plugin</artifactId>
450+
<executions>
451+
<execution>
452+
<id>process-dockerfile</id>
453+
<phase>process-resources</phase>
454+
<goals>
455+
<goal>copy-resources</goal>
456+
</goals>
457+
<configuration>
458+
<resources>
459+
<resource>
460+
<directory>src/main/docker</directory>
461+
<filtering>true</filtering>
462+
</resource>
463+
</resources>
464+
<outputDirectory>${docker.dir}</outputDirectory>
465+
</configuration>
466+
</execution>
467+
</executions>
468+
</plugin>
469+
<plugin>
470+
<groupId>org.exist-db.maven.plugins</groupId>
471+
<artifactId>public-xar-repo-plugin</artifactId>
472+
<executions>
473+
<execution>
474+
<id>fetch-xars</id>
475+
<phase>generate-resources</phase>
476+
<goals>
477+
<goal>resolve</goal>
478+
</goals>
479+
<configuration>
480+
<repoUri>${public.xar.repo.uri}</repoUri>
481+
<outputDirectory>${docker.context.dir}</outputDirectory>
482+
<existDbVersion>${project.version}</existDbVersion>
483+
<packages>
484+
<package>
485+
<abbrev>templating</abbrev>
486+
<version>${html-templating.xar.version}</version>
487+
</package>
488+
<package>
489+
<abbrev>githubxq</abbrev>
490+
<version>${githubxq.xar.version}</version>
491+
</package>
492+
<package>
493+
<abbrev>crypto</abbrev>
494+
<version>${crypto.xar.version}</version>
495+
</package>
496+
<package>
497+
<abbrev>exist-sparql</abbrev>
498+
<version>${sparql.xar.version}</version>
499+
</package>
500+
</packages>
501+
</configuration>
502+
</execution>
503+
</executions>
504+
</plugin>
505+
<plugin>
506+
<groupId>com.evolvedbinary.maven.mfrey</groupId>
507+
<artifactId>copy-maven-plugin</artifactId>
508+
<configuration>
509+
<showfiles>true</showfiles>
510+
</configuration>
511+
<executions>
512+
<execution>
513+
<id>copy-xar-to-docker-context</id>
514+
<phase>package</phase>
515+
<goals>
516+
<goal>copy</goal>
517+
</goals>
518+
<configuration>
519+
<resources>
520+
<resource>
521+
<workOnFullPath>true</workOnFullPath>
522+
<directory>${project.build.directory}</directory>
523+
<includes>*.xar</includes>
524+
<paths>
525+
<path>
526+
<from>${project.build.directory}</from>
527+
<to>${docker.context.dir}</to>
528+
</path>
529+
</paths>
530+
<replaceExisting>true</replaceExisting>
531+
</resource>
532+
</resources>
533+
</configuration>
534+
</execution>
535+
</executions>
536+
</plugin>
537+
<plugin>
538+
<groupId>io.fabric8</groupId>
539+
<artifactId>docker-maven-plugin</artifactId>
540+
<configuration>
541+
<verbose>true</verbose>
542+
<images>
543+
<image>
544+
<name>srophe/srophe:%v</name>
545+
<alias>srophe</alias>
546+
<build>
547+
<tags>
548+
<tag>latest</tag>
549+
</tags>
550+
<dockerFile>${docker.dir}/Dockerfile</dockerFile>
551+
<contextDir>${docker.context.dir}</contextDir>
552+
<buildx>
553+
<platforms>
554+
<platform>linux/amd64</platform>
555+
<platform>linux/arm64</platform>
556+
</platforms>
557+
</buildx>
558+
</build>
559+
</image>
560+
</images>
561+
</configuration>
562+
<executions>
563+
<execution>
564+
<id>build-image</id>
565+
<phase>package</phase>
566+
<goals>
567+
<goal>build</goal>
568+
</goals>
569+
</execution>
570+
<execution>
571+
<id>push-image</id>
572+
<phase>deploy</phase>
573+
<goals>
574+
<goal>push</goal>
575+
</goals>
576+
</execution>
577+
</executions>
578+
</plugin>
579+
</plugins>
580+
</build>
581+
</profile>
435582
</profiles>
436583

437584
<pluginRepositories>

src/main/docker/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM evolvedbinary/elemental:${elemental.version}
2+
3+
# Copy Majlis dependencies XAR fiels to Elemental's autodeploy folder
4+
COPY templating-${html-templating.xar.version}.xar /elemental/autodeploy/
5+
COPY githubxq-${githubxq.xar.version}.xar /elemental/autodeploy/
6+
COPY expath-crypto-module-${crypto.xar.version}.xar /elemental/autodeploy/
7+
COPY exist-sparql-${sparql.xar.version}.xar /elemental/autodeploy/
8+
9+
# Copy Srophe XAR to Elemental's autodeploy folder
10+
COPY ${package-final-name}.xar /elemental/autodeploy/
11+
12+
# Build-time metadata as defined at http://label-schema.org
13+
# and used by autobuilder @hooks/build
14+
LABEL org.label-schema.build-date=${maven.build.timestamp} \
15+
org.label-schema.description="${project.description}" \
16+
org.label-schema.name="${project.name}" \
17+
org.label-schema.schema-version="1.0" \
18+
org.label-schema.url="${project.url}" \
19+
org.label-schema.vcs-ref=${build-commit-abbrev} \
20+
org.label-schema.vcs-url="${project.scm.url}" \
21+
org.label-schema.vendor="Winona Salesky" \
22+
org.opencontainers.image.source="${project.scm.url}"
23+
24+
EXPOSE 8080 8443

0 commit comments

Comments
 (0)