Skip to content

Commit

Permalink
IntelliJ IDEA run configurations for backend
Browse files Browse the repository at this point in the history
  • Loading branch information
dapolach committed Sep 14, 2024
1 parent 756c0b2 commit 785d773
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
# backend excludes
backend/target/**
backend/build/**
backend/local.env
**/.gradle/**
20 changes: 20 additions & 0 deletions .run/Klabis Backend (TestContainers).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Klabis Backend (TestContainers)" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="envFilePaths">
<option value="$PROJECT_DIR$/backend/local.env" />
</option>
<module name="club.zabiny.klabis.test" />
<selectedOptions>
<option name="environmentVariables" />
</selectedOptions>
<option name="SPRING_BOOT_MAIN_CLASS" value="club.klabis.KlabisAppWithTestContainers" />
<extension name="software.aws.toolkits.jetbrains.core.execution.JavaAwsConnectionExtension">
<option name="credential" />
<option name="region" />
<option name="useCurrentConnection" value="false" />
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
20 changes: 20 additions & 0 deletions .run/Klabis Backend.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Klabis Backend" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="envFilePaths">
<option value="$PROJECT_DIR$/backend/local.env" />
</option>
<module name="club.zabiny.klabis.main" />
<selectedOptions>
<option name="environmentVariables" />
</selectedOptions>
<option name="SPRING_BOOT_MAIN_CLASS" value="club.klabis.KlabisApplication" />
<extension name="software.aws.toolkits.jetbrains.core.execution.JavaAwsConnectionExtension">
<option name="credential" />
<option name="region" />
<option name="useCurrentConnection" value="false" />
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
19 changes: 19 additions & 0 deletions .run/Run Klabis Docker Image.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Klabis Docker Image" type="docker-deploy" factoryName="docker-image" server-name="Docker">
<deployment type="docker-image">
<settings>
<option name="imageTag" value="registry.polach.cloud/zbm/web-2.0/klabis:0.1-SNAPSHOT" />
<option name="containerName" value="klabis-test" />
<option name="portBindings">
<list>
<DockerPortBindingImpl>
<option name="containerPort" value="8443" />
<option name="hostPort" value="9443" />
</DockerPortBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
30 changes: 25 additions & 5 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Klabis backend

## Konfigurace - promenne prostredi (environment variables)
- `GOOGLE_CLIENT_ID`: OAuth2 google client ID pro prihlaseni pres Google
- `GOOGLE_CLIENT_SECRET`: OAuth2 google client secret pro prihlaseni pres Google

## Spusteni na localhost

Aplikace ma nakonfigurovane prostredi pomoci [TestContainers](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.testcontainers.at-development-time). Pro spusteni je potreba mit nainstalovany docker. Spusteni je pak mozne pomoci prikazu
Expand All @@ -11,20 +15,36 @@ Alternativne lze aplikaci spolecne s TestContainers spustit pomoci java main tri

Aplikace je po spusteni dostupna na URL: https://localhost:8443 (URL pro Swagger API dokumentaci je https://localhost:8443/swagger-ui/index.html)

# DevOps
### IntelliJ IDEA

Po importu repozitare to IntelliJ IDEA budou pridany i Run configurations:
- `Klabis Backend (TestContainers)` - doporuceny zpusob spusteni: spusteni aplikace spolu s Test containers (vyzaduje nainstalovany docker).
- `Klabis Backend` - spusteni aplikace BEZ test containers
- `Run Klabis Docker image` - spusteni aplikace z docker image (musi byt jiz vybuildovan)

Pro spusteni aplikace pomoci techto predpripravenych konfiguraci je potreba pripravit soubor `local.env`. Zkopirujte `local.env.example` a upravte pokud je potreba provest nejake zmeny

## DevOps

## Autorizacni server
### Autorizacni server

### Vygenerovani noveho klice pro JWT tokeny
#### Vygenerovani noveho klice pro JWT tokeny
`club.klabis.config.authserver.generatejwtkeys.JKWKeyGenerator`

### Import certifikatu pro HTTPS
#### Import certifikatu pro HTTPS
Certifikat v repozitari je self-signed.

Pro import jineho certifikatu ze souboru (napr. `myCertificate.crt`) je mozne pouzit tento prikaz :
```shell
keytool -import -alias klabisSSL -file myCertificate.crt -keystore backend/src/main/resources/https/keystore.p12 -storepass secret
```

Additional info for example [here](https://www.thomasvitale.com/https-spring-boot-ssl-certificate/)

Additional info for example [here](https://www.thomasvitale.com/https-spring-boot-ssl-certificate/)
#### Konverze Let's Encryt certificatu na `.p12`

Pro konverzi `.pem` certifikatu vygenerovanych let's encrypt certbotem do `.p12` souboru pro backend by melo byt mozne pouzit nasledujici prikaz:

```shell
openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out backend/src/main/resources/https/keystore.p12 -name klabisSSL -CAfile chain.pem -caname root -password secret
```
7 changes: 7 additions & 0 deletions backend/local.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://console.cloud.google.com/apis/credentials/oauthclient/78220776170-nd1hrjmgipf2dv9e8np4qjv7tb8h7as5.apps.googleusercontent.com?project=youtubevideosstream
#GOOGLE_CLIENT_ID=
#GOOGLE_CLIENT_SECRET=

DOCKER_IMAGE_NAME=
DOCKER_USERNAME=
DOCKER_PASSWORD=

0 comments on commit 785d773

Please sign in to comment.