Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerize #33

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Accounting application for the LgHS


## Devenv, compile and run

1. create an alias for docker-compose
```bash
alias dcacc='docker-compose -p lghs-accounting -f path/to/accounting/dev-env/docker-compose.yml'
```

2. launch db and keycloak
```bash
dcacc up -d db keycloak
```

3. init db (only the first time you launch the db)
```bash
cat prepare_db.sql | dcacc exec -T db psql -Upostgres
```

4. generate jook tables
```bash
dcacc run --rm app gradle --stacktrace jooq
```

5. launch app
```bash
dcacc up -d
```

7. add entry to host `127.0.0.1 accounting.local` and connect to https://accounting.local or connect to http://localhost:8080




## Dependencies

You'll need a postgresql database and a compiled version of [coda-rs](https://github.com/bendem/coda-rs/tree/develop).
Expand Down
13 changes: 13 additions & 0 deletions dev-env/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM httpd:2.4

RUN mkdir -p /usr/local/apache2/conf/sites/ /usr/local/apache2/htdocs/login
RUN echo 'IncludeOptional /conf/sites/*.conf' | tee -a /usr/local/apache2/conf/httpd.conf

COPY resources/custom.conf /conf/sites/custom.conf
COPY resources/key /key
COPY resources/cert /cert





21 changes: 21 additions & 0 deletions dev-env/apache/resources/cert
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDczCCAlugAwIBAgIUaDm8Odr9Md37KJh+ddvLHtf+fn0wDQYJKoZIhvcNAQEL
BQAwSDELMAkGA1UEBhMCQkUxEzARBgNVBAgM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HML7D5qwFdiIQByco7js8DQ=
-----END CERTIFICATE-----
27 changes: 27 additions & 0 deletions dev-env/apache/resources/custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Listen 443

ServerName accounting.local


<VirtualHost *:443>

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule ssl_module modules/mod_ssl.so

SSLEngine on
SSLCertificateFile "/cert"
SSLCertificateKeyFile "/key"


ProxyPreserveHost On
ProxyPass / http://app:8080/
ProxyPassReverse / http://app:8080/


</VirtualHost>

28 changes: 28 additions & 0 deletions dev-env/apache/resources/key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDI0/aJKsQNtM65
+/KxLPsJmJb5rWbUIBRg0I0Xyz35fAD2IisZAkeQVejAGm19G/SVSK+IssVL59NC
5/vK4CyANWcpcEP2jdqjgBoCkia08rCg6z4vpwUATERa4PiprSkGnZAafetBvprm
eJpTp9ikIgA7AVBF4+wu4Os2hVvgLnE8bgdf4hkiBzfCSblnkfrVk52Sg/Qo/UVt
dt4iZujMxd5lPIxI7vt8ppK+eoLr7SiNg85wEcymqGQN0gCxXC/R0k++unZX51Sf
cQaF7xSPbW0K+o2CO6ZHaliC1UPug+P532JM03SQZ3FfbEpDAt9Cqw/k9WLXjwma
SQxk6GnnAgMBAAECggEAcHbrQEN3yWkwv8yNS5Ux/Fy8Z5Qo2rAgWVtRODr0OOut
qijWU8oIA5dooXPrTr3CCXvL+VSL0oc/st8xDZresOm3HOim1sL35soNRtVL4ddq
/KLgj1UMIu+S9AW6m2LCb9b65SsQ/R9dpaVyX1jGpJv53xFMP+d004fXkQ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VATE KEY-----
27 changes: 27 additions & 0 deletions dev-env/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"

services:

apache:
build: apache
ports:
- 80:80
- 443:443

app:
image: registry.gitlab.com/lghs/accounting/accounting-build-docker
volumes:
- ..:/src
- $HOME/.gradle:/gradle/.gradle
user: $UID
working_dir: /src
command: ["gradle","--stacktrace","bootRun"]
ports:
- 8080:8080

db:
image: postgres:13
environment:
- POSTGRES_HOST_AUTH_METHOD=trust


4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
database_url=jdbc:postgresql:lghs_accounting
database_url=jdbc:postgresql://db/lghs_accounting
database_schema=accounting
database_driver=org.postgresql.Driver
database_user=lghs_accounting_root
database_password=
database_password=lghs_accounting_root_password
15 changes: 15 additions & 0 deletions prepare_db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
create user lghs_accounting_root with password 'lghs_accounting_root_password'; -- change it really
create database lghs_accounting owner lghs_accounting_root;

\c lghs_accounting
revoke all on schema public from public;

create user lghs_accounting_app with password 'lghs_accounting_app_password'; -- change it really
grant connect on database lghs_accounting to lghs_accounting_app;

grant usage on schema public to lghs_accounting_root;
grant usage on schema public to lghs_accounting_app;

create extension "uuid-ossp";
create extension pgcrypto;
create extension btree_gist;
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package be.lghs.accounting.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand All @@ -28,4 +31,10 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
.addResourceLocations("classpath:/public/")
.setCacheControl(staticCacheControl);
}


@Bean
public JavaMailSender javaMailSender() {
return new JavaMailSenderImpl();
}
}
8 changes: 4 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ logging.config: classpath:logback-spring.xml
lghs.accounting:
average-monthly-rent: 855
coda-rs: "../coda-rs"
deploy-url: "http://localhost:${server.port:8080}"
deploy-url: "https://accounting.local:${server.port:''}"

spring:
profiles:
active: dev

datasource:
url: jdbc:postgresql:lghs_accounting
url: jdbc:postgresql://db/lghs_accounting
username: lghs_accounting_app
password: 'change-me'
password: 'lghs_accounting_app_password'

flyway:
url: ${spring.datasource.url}
user: lghs_accounting_root
password: 'change-me'
password: 'lghs_accounting_root_password'
schemas: accounting

security:
Expand Down