Skip to content

Commit

Permalink
Add container and GitHub build action
Browse files Browse the repository at this point in the history
  • Loading branch information
skodapetr committed Jan 30, 2024
1 parent 1002690 commit d2a3e0d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build-docker
on:
push:
branches:
- 'main'
- 'develop'
tags:
- '*'
jobs:
publish-docker:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build nad push
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
push: true
tags: ghcr.io/datagov-cz/isds-adapter:${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM openjdk:21-slim-bookworm as build
WORKDIR /opt/isds-adapter/
COPY ./ ./

RUN chmod u+x ./mvnw && ./mvnw package

FROM openjdk:21-slim-bookworm
COPY --from=build /opt/isds-adapter/dist /opt/isds-adapter/
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ Ignore any message older than one day.
For documentation about ISIS see [Poradna ISDS](https://www.poradnaisds.cz/) or [Provozní řád ISDS](https://info.mojedatovaschranka.cz/info/cs/80.html).

## Requirements
* Java 16
* Maven
* Java 21
* git client

## Install from source
Clone this repository and use maven to build the program.
```
git clone https://github.com/opendata-mvcr/nkod-isds.git
cd nkod-isds
mvn install
mvnw package
```
result of the build is saved into ```dist``` directory.
Update configuration file ```dist/configuration.properties```.
```
cd dist
java -DconfigurationFile=./configuration.properties -jar isds-0.0.0.jar
java -DconfigurationFile=./configuration.properties -jar isds-adapter.jar
```
You may need to remove certificates in ```dist/certificates``` and download valid production/test certificate.

Expand Down Expand Up @@ -52,5 +51,12 @@ If either of the conditions does not hold, an _ignore_ entry is created, and the
Otherwise, an _accept_ record for the message is created, the first `.txt` attachment
is downloaded, and the message is _markMessageAsDownloaded_ in the ISDS.

## Environment properties
Configuration from the configuration file can be overwritten using environment variables.
Program support following environment properties:
- ISDS_LOGIN - replace `login`.
- ISDS_PASSWORD - replace `password`.
- ISDS_URL - replace `url`.

Tento repozitář je udržován v rámci projektu OPZ č. CZ.03.4.74/0.0/0.0/15_025/0013983.
![Evropská unie - Evropský sociální fond - Operační program Zaměstnanost](https://data.gov.cz/images/ozp_logo_cz.jpg)
4 changes: 1 addition & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>
cz.gov.data.isds.AppEntry
</mainClass>
<mainClass>cz.gov.data.isds.AppEntry</mainClass>
</manifest>
</archive>
<outputDirectory>
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/cz/gov/data/isds/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,26 @@ private void loadFromFile(File file) throws IOException {
properties.load(stream);
}
//
this.login = getProperty(properties, "login");
this.password = getProperty(properties, "password");
this.url = getProperty(properties, "url");
this.login = getEnvOrProperty(properties, "login", "ISDS_LOGIN");
this.password = getEnvOrProperty(properties, "password", "ISDS_PASSWORD");
this.url = getEnvOrProperty(properties, "url", "ISDS_URL");
//
this.outputMessages = getProperty(properties, "output.messages");
this.outputAttachments = getProperty(properties, "output.attachments");
this.certificatesDirectory = getProperty(properties, "certificates");
this.downloadInterval = Integer.parseInt(
getProperty(properties, "download_interval_in_minutes"));
}

private String getEnvOrProperty(
Properties properties, String property, String environment) {
String environmentValue = System.getenv(environment);
if (environmentValue != null) {
return environmentValue;
}
return getProperty(properties, property);
}

private String getProperty(Properties properties, String name) {
final String value;
try {
Expand Down

0 comments on commit d2a3e0d

Please sign in to comment.