Merge branch '41-docker-how-to-for-app-usage' into 'dev'
Resolve "Docker how-to for app usage" Closes #41 See merge request sa4-2020/the-sanmarinoes/backend!58
This commit is contained in:
commit
5f26a94052
8 changed files with 131 additions and 51 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
||||||
.idea/**
|
.idea/**
|
||||||
|
|
||||||
|
data/**/*
|
||||||
|
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
|
||||||
# Compiled class file
|
# Compiled class file
|
||||||
|
@ -138,4 +140,4 @@ gradle-app.setting
|
||||||
# gradle/wrapper/gradle-wrapper.properties
|
# gradle/wrapper/gradle-wrapper.properties
|
||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
*.iml
|
*.iml
|
||||||
|
|
|
@ -63,4 +63,3 @@ code_quality:
|
||||||
- build/reports/cpd/cpdCheck.xml
|
- build/reports/cpd/cpdCheck.xml
|
||||||
#create a report on the quality of the code
|
#create a report on the quality of the code
|
||||||
expose_as: 'Code Quality Report'
|
expose_as: 'Code Quality Report'
|
||||||
allow_failure: true
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
FROM openjdk:13-jdk-alpine
|
FROM openjdk:13-jdk-alpine
|
||||||
ENV DB_URL ""
|
|
||||||
ENV DB_USER ""
|
|
||||||
ENV DB_PASS ""
|
|
||||||
ARG JAR_FILE=build/libs/smarthut*.jar
|
ARG JAR_FILE=build/libs/smarthut*.jar
|
||||||
|
|
||||||
COPY ${JAR_FILE} app.jar
|
COPY ${JAR_FILE} app.jar
|
||||||
|
|
||||||
|
ENV SMARTHUT_THIS_VALUE_IS_PROD_IF_THIS_IS_A_CONTAINER_PIZZOCCHERI=prod
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
ENTRYPOINT ["java","-jar","/app.jar"]
|
ENTRYPOINT ["java","-jar","/app.jar"]
|
||||||
|
|
13
HELP.md
13
HELP.md
|
@ -1,13 +0,0 @@
|
||||||
# Getting Started
|
|
||||||
|
|
||||||
### Reference Documentation
|
|
||||||
For further reference, please consider the following sections:
|
|
||||||
|
|
||||||
* [Official Gradle documentation](https://docs.gradle.org)
|
|
||||||
* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.4.RELEASE/gradle-plugin/reference/html/)
|
|
||||||
|
|
||||||
### Additional Links
|
|
||||||
These additional references should also help you:
|
|
||||||
|
|
||||||
* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle)
|
|
||||||
|
|
51
README.md
51
README.md
|
@ -1,2 +1,53 @@
|
||||||
# backend
|
# backend
|
||||||
|
|
||||||
|
## Installation guide
|
||||||
|
|
||||||
|
In order to install a SmartHut.sm, you can use *Docker* and *Docker Compose*
|
||||||
|
in order to create che corresponding containers.
|
||||||
|
|
||||||
|
Use the following `docker-compose.yml` example file. Change the values
|
||||||
|
of `$PASSWORD` and `$SECRET` to respectively the chosen PostgreSQL password
|
||||||
|
and the JWT secret used to run the server. `$SECRET` must be at least 64 chars long.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
services:
|
||||||
|
smarthutdb:
|
||||||
|
restart: always
|
||||||
|
image: postgres:12-alpine
|
||||||
|
container_name: smarthutdb
|
||||||
|
volumes:
|
||||||
|
- ./data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
PGDATA: /var/lib/postgresql/data/data
|
||||||
|
POSTGRES_DB: smarthut
|
||||||
|
POSTGRES_USERNAME: postgres
|
||||||
|
POSTGRES_PASSWORD: $PASSWORD
|
||||||
|
|
||||||
|
smarthutbackend:
|
||||||
|
restart: always
|
||||||
|
image: smarthutsm/smarthut-backend:M1
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
environment:
|
||||||
|
- POSTGRES_JDBC=jdbc:postgresql://smarthutdb:5432/smarthut
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASS=$PASSWORD
|
||||||
|
- SECRET=$SECRET
|
||||||
|
- MAIL_HOST=smtp.gmail.com
|
||||||
|
- MAIL_PORT=587
|
||||||
|
- MAIL_STARTTLS=true
|
||||||
|
- MAIL_USER=smarthut.sm@gmail.com
|
||||||
|
- MAIL_PASS=dcadvbagqfkwbfts
|
||||||
|
- BACKEND_URL=http://localhost:8080
|
||||||
|
- FRONTEND_URL=http://localhost
|
||||||
|
|
||||||
|
smarthut:
|
||||||
|
restart: always
|
||||||
|
image: smarthutsm/smarthut:M1
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
environment:
|
||||||
|
- BACKEND_URL=http://localhost:8080
|
||||||
|
```
|
||||||
|
|
33
src/main/resources/application-dev.properties
Normal file
33
src/main/resources/application-dev.properties
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
spring.http.converters.preferred-json-mapper=gson
|
||||||
|
spring.datasource.url=jdbc:postgresql://localhost:5432/smarthut
|
||||||
|
spring.datasource.username=postgres
|
||||||
|
spring.datasource.password=
|
||||||
|
|
||||||
|
# Hibernate properties
|
||||||
|
spring.jpa.database=POSTGRESQL
|
||||||
|
spring.jpa.show-sql=false
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
|
||||||
|
spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
|
||||||
|
jwt.secret=thiskeymustbeverylongorthethingcomplainssoiamjustgoingtowritehereabunchofgarbageciaomamma
|
||||||
|
|
||||||
|
spring.mail.test-connection=true
|
||||||
|
spring.mail.host=smtp.gmail.com
|
||||||
|
spring.mail.port=587
|
||||||
|
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||||
|
spring.mail.username=smarthut.sm@gmail.com
|
||||||
|
spring.mail.password=dcadvbagqfkwbfts
|
||||||
|
spring.mail.properties.mail.smtp.starttls.required=true
|
||||||
|
spring.mail.properties.mail.smtp.auth=true
|
||||||
|
spring.mail.properties.mail.smtp.connectiontimeout=5000
|
||||||
|
spring.mail.properties.mail.smtp.timeout=5000
|
||||||
|
spring.mail.properties.mail.smtp.writetimeout=5000
|
||||||
|
|
||||||
|
email.registrationSubject=Complete your SmartHut.sm registration
|
||||||
|
email.registration=To confirm your registration, please click here:
|
||||||
|
email.registrationPath=http://localhost:8080/register/confirm-account?token=
|
||||||
|
|
||||||
|
email.resetpasswordSubject=SmartHut.sm password reset
|
||||||
|
email.resetpassword=To reset your password, please click here:
|
||||||
|
email.resetpasswordPath=http://localhost:3000/password-reset?token=
|
39
src/main/resources/application-prod.properties
Normal file
39
src/main/resources/application-prod.properties
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
spring.http.converters.preferred-json-mapper=gson
|
||||||
|
|
||||||
|
# Database connection properties
|
||||||
|
spring.datasource.url=${POSTGRES_JDBC}
|
||||||
|
spring.datasource.username=${POSTGRES_USER}
|
||||||
|
spring.datasource.password=${POSTGRES_PASS}
|
||||||
|
|
||||||
|
# Hibernate properties
|
||||||
|
spring.jpa.database=POSTGRESQL
|
||||||
|
spring.jpa.show-sql=false
|
||||||
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
|
||||||
|
spring.jpa.properties.hibernate.format_sql=true
|
||||||
|
|
||||||
|
# JWT secret
|
||||||
|
jwt.secret=${SECRET}
|
||||||
|
|
||||||
|
# Mail connection properties
|
||||||
|
spring.mail.test-connection=true
|
||||||
|
spring.mail.host=${MAIL_HOST}
|
||||||
|
spring.mail.port=${MAIL_PORT}
|
||||||
|
spring.mail.properties.mail.smtp.starttls.enable=${MAIL_STARTTLS}
|
||||||
|
spring.mail.username=${MAIL_USER}
|
||||||
|
spring.mail.password=${MAIL_PASS}
|
||||||
|
spring.mail.properties.mail.smtp.starttls.required=${MAIL_STARTTLS}
|
||||||
|
spring.mail.properties.mail.smtp.auth=true
|
||||||
|
spring.mail.properties.mail.smtp.connectiontimeout=5000
|
||||||
|
spring.mail.properties.mail.smtp.timeout=5000
|
||||||
|
spring.mail.properties.mail.smtp.writetimeout=5000
|
||||||
|
|
||||||
|
# Registration email properties
|
||||||
|
email.registrationSubject=Complete your SmartHut.sm registration
|
||||||
|
email.registration=To confirm your registration, please click here:
|
||||||
|
email.registrationPath=${BACKEND_URL}/register/confirm-account?token=
|
||||||
|
|
||||||
|
# Password reset email properties
|
||||||
|
email.resetpasswordSubject=SmartHut.sm password reset
|
||||||
|
email.resetpassword=To reset your password, please click here:
|
||||||
|
email.resetpasswordPath=${FRONTEND_URL}/password-reset?token=
|
|
@ -1,33 +1 @@
|
||||||
spring.http.converters.preferred-json-mapper=gson
|
spring.profiles.active=${SMARTHUT_THIS_VALUE_IS_PROD_IF_THIS_IS_A_CONTAINER_PIZZOCCHERI:dev}
|
||||||
spring.datasource.url=jdbc:postgresql://localhost:5432/smarthut
|
|
||||||
spring.datasource.username=postgres
|
|
||||||
spring.datasource.password=
|
|
||||||
|
|
||||||
# Hibernate properties
|
|
||||||
spring.jpa.database=POSTGRESQL
|
|
||||||
spring.jpa.show-sql=false
|
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
|
||||||
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
|
|
||||||
spring.jpa.properties.hibernate.format_sql=true
|
|
||||||
|
|
||||||
jwt.secret=thiskeymustbeverylongorthethingcomplainssoiamjustgoingtowritehereabunchofgarbageciaomamma
|
|
||||||
|
|
||||||
spring.mail.test-connection=true
|
|
||||||
spring.mail.host=smtp.gmail.com
|
|
||||||
spring.mail.port=587
|
|
||||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
|
||||||
spring.mail.username=smarthut.sm@gmail.com
|
|
||||||
spring.mail.password=dcadvbagqfkwbfts
|
|
||||||
spring.mail.properties.mail.smtp.starttls.required=true
|
|
||||||
spring.mail.properties.mail.smtp.auth=true
|
|
||||||
spring.mail.properties.mail.smtp.connectiontimeout=5000
|
|
||||||
spring.mail.properties.mail.smtp.timeout=5000
|
|
||||||
spring.mail.properties.mail.smtp.writetimeout=5000
|
|
||||||
|
|
||||||
email.registrationSubject=Complete your SmartHut.sm registration
|
|
||||||
email.registration=To confirm your registration, please click here:
|
|
||||||
email.registrationPath=http://localhost:8080/register/confirm-account?token=
|
|
||||||
|
|
||||||
email.resetpasswordSubject=SmartHut.sm password reset
|
|
||||||
email.resetpassword=To reset your password, please click here:
|
|
||||||
email.resetpasswordPath=http://localhost:3000/password-reset?token=
|
|
Loading…
Reference in a new issue