Skip to content

Commit

Permalink
Containerization (#64)
Browse files Browse the repository at this point in the history
* DockerFile

* Fixes for pull request 63

* removed unnecessary war file

* Added docker directory to RAT exclude because coverity fails and they don't require licensing

* Removed Coverty from CI

* Swapped Dockerfile location and swapped war location to use war file that release pipeline creates

* Dockerfile added to excluded rat list

* CFE-18 was with lowercase and not dash

* Return Coverity for merging to main repository

* Documentation changes for usage instructions
  • Loading branch information
Nefarious46 authored May 15, 2024
1 parent 598886b commit 9103e34
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,21 @@ jobs:
with:
files: |
target/cfe_18.war
- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Lowercase repository name
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: 'Build Image'
run: |
docker buildx build --output type=docker --tag ghcr.io/${{ env.REPO_LC }}:${{ github.event.release.tag_name }} --tag ghcr.io/${{ env.REPO_LC }}:latest .
docker push ghcr.io/${{ env.REPO_LC }} --all-tags
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Tomcat image
FROM tomcat:8-jre8-temurin-focal

COPY target/cfe_18.war ${CATALINA_HOME}/webapps/

EXPOSE 8080

CMD ["catalina.sh", "run"]




38 changes: 37 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,42 @@ See the official documentation on https://docs.teragrep.com[docs.teragrep.com].
. Setup database according to end-user needs
. Can be deployed using https://tomcat.apache.org/tomcat-9.0-doc/deployer-howto.html[tomcat]/JBoss

== How to run in a container?

Containerized deployment for CFE-18. Requires external database to use. It uses public tomcat docker image (tomcat:8-jre8-temurin-focal)

Expected files are:

`/etc/tomcat/Catalina/localhost/cfe-18/application.properties`
`/etc/tomcat/Catalina/localhost/cfe-18/log4j2.xml`

Example files for configuration are:

`docker/application.properties`
`docker/log4j2.xml`

docker/application.properties requires configuring:

* spring.datasource.url = jdbc:mariadb://127.0.0.1:3306/cfe_18
* spring.datasource.username = username
* spring.datasource.password = password
* spring.datasource.driver-class-name = org.mariadb.jdbc.Driver

(Recommended to use MariaDB as database)


.Example run command
[source,console]
----
$ docker run -ti -v docker/application.properties:/etc/tomcat/Catalina/localhost/cfe-18/application.properties:ro -v docker/log4j2.xml:/etc/tomcat/Catalina/localhost/cfe-18/log4j2.xml:ro -p 8080:8080 ghcr.io/teragrep/cfe_18:latest
----
where

1. application.properties and log4j2.xml are mounted accordingly.
2. 8080:8080 are for external and internal ports.
3. ghcr.io/teragrep/cfe_18:latest image from Githubs image repository


== Contributing

You can involve yourself with our project by https://github.com/teragrep/cfe_18/issues/new/choose[opening an issue] or submitting a pull request.
Expand All @@ -42,4 +78,4 @@ Read more in our https://github.com/teragrep/teragrep/blob/main/contributing.ado
Contributors must sign https://github.com/teragrep/teragrep/blob/main/cla.adoc[Teragrep Contributor License Agreement] before a pull request is accepted to organization's repositories.

You need to submit the CLA only once.
After submitting the CLA you can contribute to all Teragrep's repositories.
After submitting the CLA you can contribute to all Teragrep's repositories.
33 changes: 33 additions & 0 deletions docker/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Database Config
spring.datasource.url=jdbc:mariadb://INSERT_DATASOURCE_IP:INSERT_DATASOURCE_PORT/cfe_18
spring.datasource.username=INSERT_DATASOURCE_USERNAME
spring.datasource.password=INSERT_DATASOURCE_PASSWORD
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# To show logs for each query
spring.jpa.show-sql=true
## Hibernate settings
# This prevents hibernate query turning table columns into snake case.
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
spring.jpa.hibernate.use-new-id-generator-mappings=false
# Flyway settings
spring.flyway.validateMigrationNaming=true
spring.flyway.enabled=true
spring.flyway.locations=classpath:db/migration
spring.flyway.schemas=cfe_18,cfe_03,cfe_01,cfe_07,cfe_00,flow,location
# MyBatis settings
mybatis.check-config-location=true
mybatis.config-location=classpath:mybatis-config.xml
# SpringDoc
application-description=@project.description@
application-version=@project.version@
springdoc.swagger-ui.syntax-highlight.activated=false
# Something to do with spring deployed to host? IDK. trying.
server.forward-headers-strategy=framework
# Fixes flyway problem where entitymanagerfactory creates user via spring security
# Spring security
# CORS
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.max-age=3600
management.endpoints.web.cors.allowed-headers=*
management.endpoints.web.cors.allowed-methods=*
16 changes: 16 additions & 0 deletions docker/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
<Logger name="org.mybatis" level="info"/>
</Loggers>

</Configuration>
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@
<exclude>src/main/webapp/**</exclude>
<!-- Test -->
<exclude>src/test/resources/**</exclude>
<!-- Docker -->
<exclude>docker/**</exclude>
<exclude>Dockerfile</exclude>
</excludes>
</configuration>
</plugin>
Expand Down

0 comments on commit 9103e34

Please sign in to comment.