Skip to content

Commit

Permalink
Merge pull request #87 from MTES-MCT/metabase-crud
Browse files Browse the repository at this point in the history
Dev - introduced docker-compose for local env
  • Loading branch information
lwih authored Mar 19, 2024
2 parents 1e6cc49 + de31914 commit 4b1bd6a
Show file tree
Hide file tree
Showing 82 changed files with 1,168 additions and 2,019 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
name: "[Analyse] SonarCloud"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
types: [ opened, synchronize, reopened ]
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
# types: [ opened, synchronize, reopened ]
# schedule:
# - cron: "0 3 * * *" # 3am every night
workflow_dispatch:
Expand Down
46 changes: 17 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#########################
# FRONTEND
#########################
#########################

FRONTEND_DIR := frontend

.PHONY: front-install front-start front-build front-test front-coverage front-lint front-visualize-bundle front-sourcemap
Expand Down Expand Up @@ -34,16 +34,13 @@ front-sourcemap:
front-visualize-bundle:
cd $(FRONTEND_DIR) && npx vite-bundle-visualizer


#########################
# END FRONTEND
#########################


#########################
# BACKEND
#########################
#########################
BACKEND_DIR := backend
BACKEND_CONFIGURATION_FOLDER=$(shell pwd)/infra/configurations/backend/

Expand All @@ -70,45 +67,36 @@ back-start-local:
back-clean-archi:
cd $(BACKEND_DIR)/tools && ./check-clean-architecture.sh


#########################
# END BACKEND
#########################



#########################
# MAINTENANCE
# DOCKER
#########################
#########################
.PHONY: docker-prune logs-backend

docker-prune:
docker image prune -a
logs-backend:
docker container logs -f rapportnav_backend


#########################
# END MAINTENANCE
#########################
INFRA_DIR := infra

.PHONY: docker-prune docker-logs-backend

docker-prune:
docker image prune -a
docker-logs-backend:
docker container logs -f backend


.PHONY: docker-build-app
.PHONY: docker-build-back docker-build-front docker-run-local

docker-build-app:
docker buildx build -f infra/docker/app/Dockerfile . \
-t rapportnav-app:$(VERSION) \
-t rapportnav-app:latest \
--load \
--build-arg VERSION=$(VERSION) \
--build-arg ENV_PROFILE=$(ENV_PROFILE) \
--build-arg GITHUB_SHA=$(GITHUB_SHA)
docker-build-back:
cd $(INFRA_DIR) && docker compose -f docker-compose.local.yml build backend

docker-build-front:
cd $(INFRA_DIR) && docker compose -f docker-compose.local.yml build frontend

docker-run-local:
docker-compose -f ./infra/docker-compose.dev.yml up
cd $(INFRA_DIR) && docker compose -f docker-compose.local.yml up -d

# END DOCKER
#########################


11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ Before trying to run the project, make sure you have:

### Running the project

From the root dir, the following commands are available:
The app is fully dockerized for local development. Run the command `make docker-run-local`

- backend
- install dependencies: make back-clean-install
- run local backend: make back-start-dev (http://localhost:80/)
- frontend
- install dependencies: make front-install
- run local frontend: make front-start (http://localhost:5173/)
- frontend is available at http://localhost:5173/
- backend is available at http://localhost:80/

## Security and Vulnerabilities analysis

Expand Down Expand Up @@ -87,3 +83,4 @@ two repos before deploying_:
- check the running `release` Action
- check the
pipeline [here](https://gitlab-sml.din.developpement-durable.gouv.fr/num3-exploitation/deploiement-continu/gitlab-ci/applications/rapportnav-v2/rapportnav-v2/-/pipelines)

1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ HELP.md
### Gradle ###
.gradle
build/
target/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
Expand Down
16 changes: 16 additions & 0 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencyManagement {
}

dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
implementation("org.springframework.boot:spring-boot-starter-data-jpa:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-data-rest:$springVersion")
implementation("org.springframework.boot:spring-boot-starter-web:$springVersion")
Expand Down Expand Up @@ -98,4 +99,19 @@ tasks.named<Test>("test") {
}
}

// for hot-reload:
tasks.register<Copy>("getDependencies") {
from(sourceSets.main.get().runtimeClasspath)
into("runtime/")

doFirst {
val runtimeDir = File("runtime")
runtimeDir.deleteRecursively()
runtimeDir.mkdir()
}

doLast {
File("runtime").deleteRecursively()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ fun main(args: Array<String>) {

val ctx = runApplication<RapportNavApplication>(*args)

val isSentryEnabled: String? = ctx.environment.getProperty("sentry.enabled")
val sentryDsn: String? = ctx.environment.getProperty("sentry.dsn")
val isSentryEnabled: String? = ctx.environment.getProperty("rapportnav.sentry.enabled")
val sentryDsn: String? = ctx.environment.getProperty("rapportnav.sentry.dsn")

if (isSentryEnabled == "true") {
Sentry.init { options ->
options.dsn = sentryDsn
options.proxy = SentryOptions.Proxy(
ctx.environment.getProperty("sentry.proxy.host"),
ctx.environment.getProperty("sentry.proxy.port")
ctx.environment.getProperty("rapportnav.sentry.proxy.host"),
ctx.environment.getProperty("rapportnav.sentry.proxy.port")
)
options.tracesSampleRate = 1.0
}
Expand Down
58 changes: 36 additions & 22 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,40 +1,54 @@
server.port=0080
# Set root logger to DEBUG level
# logging.level.root=DEBUG
server.servlet.request.logging.enabled=true
server.servlet.request.logging.level=INFO
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.security=DEBUG
spring.data.rest.base-path=/api
security.key=somerandomkeywhichislongenoughtoalignwiththejwtspecification
################
################
# Spring
spring.mvc.static-path-pattern=/**
spring.web.resources.static-locations=file:${STATIC_FILES_PATH}
# JPA
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true
# spring.datasource.url=${env.db.url}
spring.datasource.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres
spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
# Rest API
spring.data.rest.base-path=/api
# database migrations
spring.flyway.enabled=true
spring.flyway.baseline-on-migrate=true
spring.flyway.locations=classpath:/db/migration,classpath:/db/testdata
spring.flyway.out-of-order=true
# hot reload:
#spring.devtools.livereload.enabled=${spring.devtools.livereload.enabled}
################
################
# Server
server.port=0080
server.servlet.request.logging.enabled=true
server.servlet.request.logging.level=INFO
################
################
# GraphQL API
graphql.cors-enabled=true
graphql.cors.allowed-origins=*
graphql.cors.allowed-methods=GET, HEAD, POST
spring.graphql.graphiql.enabled=true
spring.graphql.graphiql.path=/graphiql
# Sentry log & perf tracking
sentry.enabled=true
sentry.dsn=https://[email protected]/121
sentry.proxy.host=172.27.229.197
sentry.proxy.port=8090
#sentry.exception-resolver-order=-2147483647
sentry.traces-sample-rate=1.0
sentry.environment=production
################
################
# Logging
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.security=DEBUG
################
################
# Security
security.key=somerandomkeywhichislongenoughtoalignwiththejwtspecification
################
################
# Sentry
rapportnav.sentry.enabled=${sentry.enabled}
rapportnav.sentry.dsn=${sentry.dsn}
rapportnav.sentry.proxy.host=${host.proxy.host}
rapportnav.sentry.proxy.port=${host.proxy.port}
rapportnav.sentry.traces-sample-rate=${sentry.traces-sample-rate}
rapportnav.sentry.environment=${sentry.environment}
sentry.use-git-commit-id-as-release=true
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.

33 changes: 0 additions & 33 deletions backend/target/classes/application.properties

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4b1bd6a

Please sign in to comment.