From ea93fc778906b371751b1c830a6e94095dd8327f Mon Sep 17 00:00:00 2001 From: lwih Date: Wed, 31 Jan 2024 14:00:37 +0100 Subject: [PATCH 01/18] metabase local - save progress --- docker-compose.yml | 9 +-- infra/docker-compose.dev.yml | 12 ++- infra/docker/app/DockerfileDev | 137 ++++++++++++++++++++------------- 3 files changed, 92 insertions(+), 66 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9d58534d..a516d88b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,13 +3,10 @@ services: app: build: context: . - dockerfile: infra/docker/app/Dockerfile + dockerfile: infra/docker/app/DockerfileDev target: build-all ports: - # - ${BACKEND_HTTP_PORT}:8880 - - 8880:8880 - - 80:80 - - 8000:8000 + - "80:80" volumes: - ./frontend:/tmp/frontend depends_on: @@ -39,7 +36,7 @@ services: metabase: image: metabase/metabase:latest ports: - - 3000:3000 + - "3000:3000" volumes: - metabase_data:/metabase-data environment: diff --git a/infra/docker-compose.dev.yml b/infra/docker-compose.dev.yml index 88c04548..90064d9a 100644 --- a/infra/docker-compose.dev.yml +++ b/infra/docker-compose.dev.yml @@ -19,11 +19,10 @@ services: backend: build: context: .. - dockerfile: ./infra/docker/app/DockerfileDev.old + dockerfile: ./infra/docker/app/DockerfileDev target: run-backend ports: - - 80:80 - - 8880:8880 + - "80:80" volumes: - ./backend:/tmp/backend depends_on: @@ -33,18 +32,17 @@ services: frontend: build: context: .. - dockerfile: ./infra/docker/app/DockerfileDev.old + dockerfile: ./infra/docker/app/DockerfileDev target: run-frontend ports: - - 5173:5173 - # - 3000:3000 + - "5173:5173" volumes: - ./frontend:/tmp/frontend metabase: image: metabase/metabase:latest ports: - - 3000:3000 + - "3000:3000" volumes: - metabase_data:/metabase-data environment: diff --git a/infra/docker/app/DockerfileDev b/infra/docker/app/DockerfileDev index da200d69..0de6e473 100644 --- a/infra/docker/app/DockerfileDev +++ b/infra/docker/app/DockerfileDev @@ -5,82 +5,113 @@ ARG GITHUB_SHA=NO_COMMIT ARG VERSION=NO_VERSION +######################################### +## Build rapportnav backend with gradle # +######################################### +#FROM gradle:8.5-jdk17 as build-backend +# +#ARG GITHUB_SHA +#ARG VERSION +# +#WORKDIR /tmp +# +#COPY backend/ /tmp +#COPY backend/pom.xml /tmp/backend/POM_WITH_ENV_VARS +# +#RUN gradle clean assemble + + ######################################## -# Build rapportnav backend with maven # +# Build rapportnav backend with gradle # ######################################## -FROM maven:3.8.5-openjdk-17-slim as build-backend +FROM gradle:8.5-jdk17 as run-backend ARG GITHUB_SHA ARG VERSION WORKDIR /tmp/backend -COPY backend/pom.xml pom.xml -RUN mvn dependency:go-offline -B COPY backend/ /tmp/backend -COPY backend/pom.xml /tmp/backend/POM_WITH_ENV_VARS -RUN sed -e 's/COMMIT_TO_CHANGE/${GITHUB_SHA}/' \ - -e 's/VERSION_TO_CHANGE/${VERSION}/' \ - POM_WITH_ENV_VARS > pom.xml - -RUN mvn clean package -DskipTests=true - -######################################## -# Run Application # -######################################## -FROM azul/zulu-openjdk-debian:17-latest as run-backend - -WORKDIR /home/rapportnav - -ARG VERSION -ENV VERSION=$VERSION - -ARG ENV_PROFILE -ENV ENV_PROFILE=dev - -ENV SPRING_PROFILES_ACTIVE=$ENV_PROFILE - -# ENV REACT_APP_ENV=$ENV_PROFILE -ENV ENV_DB_URL="" - -# copy backend related things -COPY --from=build-backend /tmp/backend/build/libs/rapportnav-${VERSION}.jar /home/rapportnav -COPY infra/configurations/backend /home/rapportnav/configurations/ - - -# RUN mkdir /home/rapportnav/public -# COPY --from=buildSourcemaps /tmp/frontend/build /home/rapportnav/public/ -# COPY --from=build-frontend /tmp/frontend/dist /home/rapportnav/public/ -# COPY --from=build-frontend /tmp/infra/docker/tmp/env.sh /home/rapportnav/ - -# Add logs folder to be mounted as volume -RUN mkdir /home/rapportnav/logs - -# Set up environement variable that define the root folder use for serving static files -# It must point to the front (React) files -# ENV STATIC_FILES_PATH=/home/rapportnav/public - - -# CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" -CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" - - +COPY infra/ /tmp/infra +EXPOSE 80 +RUN gradle bootRun --args='--spring.profiles.active=prod --spring.config.additional-location=/tmp/infra/configurations/backend/' ######################################## # Build frontend # ######################################## # Stage 1: Build npm dependencies -FROM node:18 AS npm-dependencies +FROM node:20 AS npm-dependencies WORKDIR /tmp/frontend COPY frontend/package.json frontend/package-lock.json ./ RUN npm install # Stage 2: Build the application -FROM node:18 AS run-frontend +FROM node:20 AS run-frontend WORKDIR /tmp/frontend COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules COPY frontend . EXPOSE 5173 RUN npm run dev --mode dev --host + +######################################### +## Build frontend # +######################################### +## Stage 1: Download npm dependencies +## this stage will not run if dependencies have not changed +#FROM node:18 AS npm-dependencies +#WORKDIR /tmp/frontend +#COPY frontend/package.json frontend/package-lock.json ./ +#RUN npm ci +# +## Stage 2: Build the application +#FROM node:18 AS build-frontend +#WORKDIR /tmp/frontend +#COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules +#COPY frontend . +#RUN npm run build --verbose + +######################################## +# Run Application # +######################################## +#FROM azul/zulu-openjdk-debian:17-latest as run-backend +# +#WORKDIR /home/rapportnav +# +#ARG VERSION=1.0.2 +#ENV VERSION=$VERSION +# +#ARG ENV_PROFILE +#ENV ENV_PROFILE=dev +# +#ENV SPRING_PROFILES_ACTIVE=$ENV_PROFILE +# +## ENV REACT_APP_ENV=$ENV_PROFILE +#ENV ENV_DB_URL="" +# +## copy backend related things +#COPY --from=build-backend /tmp/backend/build/libs/rapportnav-${VERSION}.jar /home/rapportnav +#COPY infra/configurations/backend /home/rapportnav/configurations/ +# +# +## RUN mkdir /home/rapportnav/public +## COPY --from=buildSourcemaps /tmp/frontend/build /home/rapportnav/public/ +# COPY --from=build-frontend /tmp/frontend/dist /home/rapportnav/public/ +## COPY --from=build-frontend /tmp/infra/docker/tmp/env.sh /home/rapportnav/ +# +## Add logs folder to be mounted as volume +#RUN mkdir /home/rapportnav/logs +# +## Set up environement variable that define the root folder use for serving static files +## It must point to the front (React) files +#ENV STATIC_FILES_PATH=/home/rapportnav/public +# +# +## CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" +#CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" + + + + + From db0e83612fb8779d24e9d2acf21fc30ecea3582c Mon Sep 17 00:00:00 2001 From: lwih Date: Fri, 2 Feb 2024 16:12:59 +0100 Subject: [PATCH 02/18] Dev - introduced docker-compose for local env --- Makefile | 46 +++---- backend/build.gradle.kts | 1 + .../src/main/resources/application.properties | 3 +- docker-compose.yml | 2 +- frontend/vite.config.ts | 55 ++++---- .../backend/application-dev.properties | 12 +- .../backend/application-local.properties | 1 - .../backend/application-prod.properties | 3 +- ...mpose.dev.yml => docker-compose.local.yml} | 57 ++++----- infra/docker-compose.prod.yml | 49 -------- infra/docker/app/DockerfileDev | 117 ------------------ infra/docker/app/DockerfileLocalBack | 35 ++++++ infra/docker/app/DockerfileLocalFront | 16 +++ 13 files changed, 135 insertions(+), 262 deletions(-) rename infra/{docker-compose.dev.yml => docker-compose.local.yml} (58%) delete mode 100644 infra/docker-compose.prod.yml delete mode 100644 infra/docker/app/DockerfileDev create mode 100644 infra/docker/app/DockerfileLocalBack create mode 100644 infra/docker/app/DockerfileLocalFront diff --git a/Makefile b/Makefile index 97eba8f8..4bb796df 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -34,8 +34,6 @@ front-sourcemap: front-visualize-bundle: cd $(FRONTEND_DIR) && npx vite-bundle-visualizer - -######################### # END FRONTEND ######################### @@ -43,7 +41,6 @@ front-visualize-bundle: ######################### # BACKEND ######################### -######################### BACKEND_DIR := backend BACKEND_CONFIGURATION_FOLDER=$(shell pwd)/infra/configurations/backend/ @@ -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 +######################### diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index dd68c394..1a8228dc 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -43,6 +43,7 @@ dependencyManagement { } dependencies { + runtimeOnly("org.springframework.boot:spring-boot-devtools:$springVersion") 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") diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 91c7e55a..0d304fcc 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -13,7 +13,7 @@ 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 # database migrations spring.flyway.enabled=true @@ -38,3 +38,4 @@ 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. +spring.devtools.livereload.enabled=true diff --git a/docker-compose.yml b/docker-compose.yml index a516d88b..20d4e45b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: app: build: context: . - dockerfile: infra/docker/app/DockerfileDev + dockerfile: infra/docker/app/DockerfileLocalBack target: build-all ports: - "80:80" diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 117f4d3c..7bc4dfdc 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -9,34 +9,35 @@ import dotenv from 'dotenv'; // https://vitejs.dev/config/ export default defineConfig({ - define: { - // https://www.apollographql.com/docs/react/development-testing/reducing-bundle-size - "globalThis.__DEV__": JSON.stringify(false), - }, - build: { - rollupOptions: { - output: { - format: 'es', - manualChunks(id) { - // Separate third-party dependencies into a common chunk - if (id.includes('node_modules')) { - return 'vendor'; - } - if (id.includes('src/pam')) { - return 'pam'; - } - }, - }, + define: { + // https://www.apollographql.com/docs/react/development-testing/reducing-bundle-size + "globalThis.__DEV__": JSON.stringify(false), + }, + build: { + rollupOptions: { + output: { + format: 'es', + manualChunks(id) { + // Separate third-party dependencies into a common chunk + if (id.includes('node_modules')) { + return 'vendor'; + } + if (id.includes('src/pam')) { + return 'pam'; + } }, + }, }, - plugins: [ - react(), - eslint(), - ], - server: { - proxy: { - '/api': 'http://localhost:80', - '/graphql': 'http://localhost:80' - } + }, + plugins: [ + react(), + eslint(), + ], + server: { + host: true, + proxy: { + '/api': 'http://backend:80', + '/graphql': 'http://backend:80' } + } }) diff --git a/infra/configurations/backend/application-dev.properties b/infra/configurations/backend/application-dev.properties index 7dcb2909..116f369f 100644 --- a/infra/configurations/backend/application-dev.properties +++ b/infra/configurations/backend/application-dev.properties @@ -1,10 +1,8 @@ -env.db.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres -spring.datasource.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres -host.ip=localhost:80 -spring.graphql.graphiql.enabled=true -spring.graphql.graphiql.path=/graphiql -sentry.enabled=true +env.db.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres +spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres +#Sentry +sentry.enabled=false sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 #sentry.exception-resolver-order=-2147483647 sentry.traces-sample-rate=1.0 -sentry.environment=integration +sentry.environment=dev diff --git a/infra/configurations/backend/application-local.properties b/infra/configurations/backend/application-local.properties index 900d1356..8ae3031c 100644 --- a/infra/configurations/backend/application-local.properties +++ b/infra/configurations/backend/application-local.properties @@ -1,6 +1,5 @@ env.db.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres spring.datasource.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres -host.ip=localhost:8880 #Sentry sentry.enabled=false sentry.dsn= diff --git a/infra/configurations/backend/application-prod.properties b/infra/configurations/backend/application-prod.properties index 81e1a701..a15aa54e 100644 --- a/infra/configurations/backend/application-prod.properties +++ b/infra/configurations/backend/application-prod.properties @@ -1,6 +1,5 @@ env.db.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres -host.ip=localhost:8880 #Sentry sentry.enabled=true sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 @@ -8,4 +7,4 @@ 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 \ No newline at end of file +sentry.environment=production diff --git a/infra/docker-compose.dev.yml b/infra/docker-compose.local.yml similarity index 58% rename from infra/docker-compose.dev.yml rename to infra/docker-compose.local.yml index 90064d9a..94221e8d 100644 --- a/infra/docker-compose.dev.yml +++ b/infra/docker-compose.local.yml @@ -1,43 +1,40 @@ -version: "3" -services: - db: - image: postgres:15.6-alpine - ports: - - "5432:5432" - environment: - POSTGRES_DB: rapportnavdb - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - volumes: - - db_data:/var/lib/postgresql/data - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 1s - timeout: 1s - retries: 30 +version: '3.8' +services: backend: build: context: .. - dockerfile: ./infra/docker/app/DockerfileDev - target: run-backend + dockerfile: docker/app/DockerfileLocalBack ports: - "80:80" - volumes: - - ./backend:/tmp/backend depends_on: - db - - metabase + volumes: + - ../backend:/tmp/backend + - ./infra/configurations/backend:/tmp/backend/configurations + environment: + - VERSION=1.0.3 + - ENV_PROFILE=local frontend: build: - context: .. - dockerfile: ./infra/docker/app/DockerfileDev - target: run-frontend + context: ../frontend + dockerfile: docker/app/DockerfileLocalFront ports: - "5173:5173" volumes: - - ./frontend:/tmp/frontend + - ../frontend:/tmp/frontend + + db: + image: postgres:15.6-alpine + ports: + - "5432:5432" + environment: + POSTGRES_DB: rapportnavdb + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + volumes: + - db:/var/lib/postgresql/data metabase: image: metabase/metabase:latest @@ -46,16 +43,20 @@ services: volumes: - metabase_data:/metabase-data environment: + # - MB_DB_CONNECTION_URI="db:5432/rapportnavdb?user=postgres&password=postgres" - MB_DB_CONNECTION_URI=postgres://db:5432/rapportnavdb?currentSchema=metabase - MB_DB_FILE=/metabase-data/metabase.db - MB_DB_TYPE=postgres + # - MB_DB_DBNAME=rapportnavdb + # - MB_DB_PORT=5432 - MB_DB_USER=postgres - MB_DB_PASS=postgres + # - MB_DB_HOST=db restart: always depends_on: - db volumes: - db_data: - name: db + db: + name: rapportnavdb metabase_data: diff --git a/infra/docker-compose.prod.yml b/infra/docker-compose.prod.yml deleted file mode 100644 index 78f251fa..00000000 --- a/infra/docker-compose.prod.yml +++ /dev/null @@ -1,49 +0,0 @@ -services: - app: - image: ghcr.io/mtes-mct/rapportnav2/rapportnav-app:latest - container_name: rapportnav_backend - # user: "rapportnav:${MONITORENV_LOGS_AND_BACKUPS_GID}" - environment: - - ENV_DB_URL=jdbc:postgresql://db:5432/$POSTGRES_DB?user=$POSTGRES_USER&password=$POSTGRES_PASSWORD - - SPRING_PROFILES_ACTIVE=${ENVIRONMENT} - ports: - # - ${BACKEND_HTTP_PORT}:8880 - - 8880:8880 - - 80:80 - - 8000:8000 - volumes: - - "${RAPPORTNAV_LOGS_FOLDER}:/home/rapportnav/logs" - # networks: - # - backend_network - depends_on: - - db - restart: always - logging: - driver: "json-file" - options: - max-size: "1024m" - - db: - image: postgres:15.6-alpine - volumes: - - "${RAPPORTNAV_BACKUPS_FOLDER}:/opt/rapportnav_backups" - - db:/var/lib/postgresql/data - # networks: - # - backend_network - restart: always - ports: - - "5432:5432" - environment: - POSTGRES_DB: rapportnavdb - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 1s - timeout: 1s - retries: 30 -# networks: -# backend_network: -volumes: - db: - name: rapportnavdb diff --git a/infra/docker/app/DockerfileDev b/infra/docker/app/DockerfileDev deleted file mode 100644 index 0de6e473..00000000 --- a/infra/docker/app/DockerfileDev +++ /dev/null @@ -1,117 +0,0 @@ -##################### -# Multi stage build # -##################### - -ARG GITHUB_SHA=NO_COMMIT -ARG VERSION=NO_VERSION - -######################################### -## Build rapportnav backend with gradle # -######################################### -#FROM gradle:8.5-jdk17 as build-backend -# -#ARG GITHUB_SHA -#ARG VERSION -# -#WORKDIR /tmp -# -#COPY backend/ /tmp -#COPY backend/pom.xml /tmp/backend/POM_WITH_ENV_VARS -# -#RUN gradle clean assemble - - -######################################## -# Build rapportnav backend with gradle # -######################################## -FROM gradle:8.5-jdk17 as run-backend - -ARG GITHUB_SHA -ARG VERSION - -WORKDIR /tmp/backend - -COPY backend/ /tmp/backend -COPY infra/ /tmp/infra - -EXPOSE 80 -RUN gradle bootRun --args='--spring.profiles.active=prod --spring.config.additional-location=/tmp/infra/configurations/backend/' - -######################################## -# Build frontend # -######################################## -# Stage 1: Build npm dependencies -FROM node:20 AS npm-dependencies -WORKDIR /tmp/frontend -COPY frontend/package.json frontend/package-lock.json ./ -RUN npm install - -# Stage 2: Build the application -FROM node:20 AS run-frontend -WORKDIR /tmp/frontend -COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules -COPY frontend . -EXPOSE 5173 -RUN npm run dev --mode dev --host - - -######################################### -## Build frontend # -######################################### -## Stage 1: Download npm dependencies -## this stage will not run if dependencies have not changed -#FROM node:18 AS npm-dependencies -#WORKDIR /tmp/frontend -#COPY frontend/package.json frontend/package-lock.json ./ -#RUN npm ci -# -## Stage 2: Build the application -#FROM node:18 AS build-frontend -#WORKDIR /tmp/frontend -#COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules -#COPY frontend . -#RUN npm run build --verbose - -######################################## -# Run Application # -######################################## -#FROM azul/zulu-openjdk-debian:17-latest as run-backend -# -#WORKDIR /home/rapportnav -# -#ARG VERSION=1.0.2 -#ENV VERSION=$VERSION -# -#ARG ENV_PROFILE -#ENV ENV_PROFILE=dev -# -#ENV SPRING_PROFILES_ACTIVE=$ENV_PROFILE -# -## ENV REACT_APP_ENV=$ENV_PROFILE -#ENV ENV_DB_URL="" -# -## copy backend related things -#COPY --from=build-backend /tmp/backend/build/libs/rapportnav-${VERSION}.jar /home/rapportnav -#COPY infra/configurations/backend /home/rapportnav/configurations/ -# -# -## RUN mkdir /home/rapportnav/public -## COPY --from=buildSourcemaps /tmp/frontend/build /home/rapportnav/public/ -# COPY --from=build-frontend /tmp/frontend/dist /home/rapportnav/public/ -## COPY --from=build-frontend /tmp/infra/docker/tmp/env.sh /home/rapportnav/ -# -## Add logs folder to be mounted as volume -#RUN mkdir /home/rapportnav/logs -# -## Set up environement variable that define the root folder use for serving static files -## It must point to the front (React) files -#ENV STATIC_FILES_PATH=/home/rapportnav/public -# -# -## CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" -#CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" - - - - - diff --git a/infra/docker/app/DockerfileLocalBack b/infra/docker/app/DockerfileLocalBack new file mode 100644 index 00000000..56e090e6 --- /dev/null +++ b/infra/docker/app/DockerfileLocalBack @@ -0,0 +1,35 @@ +######################################## +# Dependencies # +######################################## +# Stage 1: Build backend dependencies +FROM openjdk:17-jdk-alpine AS backend-dependencies + +WORKDIR /tmp/backend +# Copy backend Gradle build files +COPY backend/build.gradle.kts backend/settings.gradle.kts backend/gradlew ./ +COPY backend/gradle ./gradle +# Resolve and cache dependencies +RUN ./gradlew --no-daemon dependencies + + +######################################## +# Package and Serve on :80 # +######################################## +FROM backend-dependencies as backend-run + +ENV VERSION=1.0.3 +ENV ENV_PROFILE=local + +WORKDIR /tmp/backend + +COPY backend/ . + +# Copy config +COPY infra/configurations/backend ./configurations/ + +# Expose ports +EXPOSE 80 + +# Run the backend application +CMD ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=/tmp/backend/configurations/' + diff --git a/infra/docker/app/DockerfileLocalFront b/infra/docker/app/DockerfileLocalFront new file mode 100644 index 00000000..c746ea6b --- /dev/null +++ b/infra/docker/app/DockerfileLocalFront @@ -0,0 +1,16 @@ + +# Install npm dependencies +FROM node:20 AS frontend-dependencies +WORKDIR /tmp/frontend +COPY package.json package-lock.json ./ +RUN npm install + + +# Run the frontend +FROM node:20 AS frontend-run +WORKDIR /tmp/frontend +COPY . . +COPY --from=frontend-dependencies /tmp/frontend/node_modules ./node_modules +EXPOSE 5173 +CMD npm rebuild esbuild && npm run dev + From 7ac0f4fa73be7910511ac6ae4b5dd2d35cffaf06 Mon Sep 17 00:00:00 2001 From: lwih Date: Fri, 2 Feb 2024 16:18:08 +0100 Subject: [PATCH 03/18] Dev - update readme --- README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b5a35155..95b02c5d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) + From 26fd0ab2926fa8c8976560f1553b555b4e9ff606 Mon Sep 17 00:00:00 2001 From: lwih Date: Mon, 26 Feb 2024 16:36:12 +0100 Subject: [PATCH 04/18] cleanup --- .github/workflows/sonarcloud.yml | 10 ++--- docker-compose.yml | 68 -------------------------------- infra/docker/app/DockerfileCI | 17 ++------ 3 files changed, 8 insertions(+), 87 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 47b912e5..96ff47c4 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index 20d4e45b..e69de29b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,68 +0,0 @@ -version: "3" -services: - app: - build: - context: . - dockerfile: infra/docker/app/DockerfileLocalBack - target: build-all - ports: - - "80:80" - volumes: - - ./frontend:/tmp/frontend - depends_on: - - db - - metabase - # networks: - # - backend-network - - db: - image: postgres:15.6-alpine - ports: - - "5432:5432" - environment: - POSTGRES_DB: rapportnavdb - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - volumes: - - db_data:/var/lib/postgresql/data - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 1s - timeout: 1s - retries: 30 - # networks: - # - backend-network - - metabase: - image: metabase/metabase:latest - ports: - - "3000:3000" - volumes: - - metabase_data:/metabase-data - environment: - # - MB_DB_CONNECTION_URI="db:5432/rapportnavdb?user=postgres&password=postgres" - - MB_DB_CONNECTION_URI=postgres://db:5432/rapportnavdb?currentSchema=metabase - - MB_DB_FILE=/metabase-data/metabase.db - - MB_DB_TYPE=postgres - # - MB_DB_DBNAME=rapportnavdb - # - MB_DB_PORT=5432 - - MB_DB_USER=postgres - - MB_DB_PASS=postgres - # - MB_DB_HOST=db - restart: always - depends_on: - - db - # networks: - # - backend-network - -# networks: -# backend-network: -# external: false -# name: backend-network -# default: -# driver: bridge - -volumes: - db_data: - name: db - metabase_data: diff --git a/infra/docker/app/DockerfileCI b/infra/docker/app/DockerfileCI index 6d462c40..19493fcb 100644 --- a/infra/docker/app/DockerfileCI +++ b/infra/docker/app/DockerfileCI @@ -1,3 +1,5 @@ +# This file is used in the CI job for Trivy + ##################### # Multi stage build # ##################### @@ -6,23 +8,13 @@ ARG GITHUB_SHA ARG VERSION ######################################## -# Build rapportnav backend with maven # +# Build rapportnav backend with gradle # ######################################## FROM gradle:8.5-jdk17 as build-backend ARG GITHUB_SHA ARG VERSION -#WORKDIR /tmp/backend -#COPY backend/ /tmp/backend -#COPY --from=maven-dependencies /root/.m2 /root/.m2 -#COPY backend/pom.xml /tmp/backend/POM_WITH_ENV_VARS -#RUN sed -e 's/COMMIT_TO_CHANGE/${GITHUB_SHA}/' \ -# -e 's/VERSION_TO_CHANGE/${VERSION}/' \ -# POM_WITH_ENV_VARS > pom.xml -# -#RUN mvn clean package -DskipTests=true - WORKDIR /tmp/ COPY --chown=gradle:gradle backend/ /tmp/ @@ -76,9 +68,7 @@ COPY infra/configurations/backend /home/rapportnav/configurations/ # copy frontend related things RUN mkdir /home/rapportnav/public -# COPY --from=buildSourcemaps /tmp/frontend/build /home/rapportnav/public/ COPY --from=build-frontend /tmp/frontend/dist /home/rapportnav/public/ -# COPY --from=build-frontend /tmp/infra/docker/tmp/env.sh /home/rapportnav/ # Add logs folder to be mounted as volume RUN mkdir /home/rapportnav/logs @@ -87,5 +77,4 @@ RUN mkdir /home/rapportnav/logs # It must point to the front (React) files ENV STATIC_FILES_PATH=/home/rapportnav/public -# CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" From f2c1ced9580520a88c61349c29fc744689f84d0d Mon Sep 17 00:00:00 2001 From: lwih Date: Mon, 26 Feb 2024 17:44:17 +0100 Subject: [PATCH 05/18] cleanup and setting local version --- infra/docker-compose.local.yml | 2 +- infra/docker-compose.yml | 34 ---------------------------- infra/docker/app/DockerfileLocalBack | 6 +++-- 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml index 94221e8d..1e79c528 100644 --- a/infra/docker-compose.local.yml +++ b/infra/docker-compose.local.yml @@ -13,7 +13,7 @@ services: - ../backend:/tmp/backend - ./infra/configurations/backend:/tmp/backend/configurations environment: - - VERSION=1.0.3 + - VERSION=NO_VERSION - ENV_PROFILE=local frontend: diff --git a/infra/docker-compose.yml b/infra/docker-compose.yml index 2481d967..e69de29b 100644 --- a/infra/docker-compose.yml +++ b/infra/docker-compose.yml @@ -1,34 +0,0 @@ -version: "3" -services: - app: - build: - context: . - dockerfile: app/Dockerfile - target: build-all - ports: - - ${BACKEND_HTTP_PORT}:8880 - - 8000:8000 - volumes: - - ./frontend:/tmp/frontend - depends_on: - - db - - db: - image: postgres:15.6-alpine - ports: - - "5432:5432" - environment: - POSTGRES_DB: rapportnavdb - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - volumes: - - db:/var/lib/postgresql/data - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U postgres" ] - interval: 1s - timeout: 1s - retries: 30 - -volumes: - db: - name: rapportnavdb diff --git a/infra/docker/app/DockerfileLocalBack b/infra/docker/app/DockerfileLocalBack index 56e090e6..1b1f78b1 100644 --- a/infra/docker/app/DockerfileLocalBack +++ b/infra/docker/app/DockerfileLocalBack @@ -17,8 +17,10 @@ RUN ./gradlew --no-daemon dependencies ######################################## FROM backend-dependencies as backend-run -ENV VERSION=1.0.3 -ENV ENV_PROFILE=local +ARG VERSION +ENV VERSION=$VERSION +ARG ENV_PROFILE +ENV ENV_PROFILE=$ENV_PROFILE WORKDIR /tmp/backend From cc6abc416a87678e5bb07b3e5166d6e29b9b8f54 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 27 Feb 2024 15:47:27 +0100 Subject: [PATCH 06/18] docker-compose: add hot reload for backend --- backend/build.gradle.kts | 17 ++++++++++++++++- .../src/main/resources/application.properties | 4 +--- .../backend/application-local.properties | 2 ++ infra/docker/app/DockerfileLocalBack | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 1a8228dc..58771f19 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -43,7 +43,7 @@ dependencyManagement { } dependencies { - runtimeOnly("org.springframework.boot:spring-boot-devtools:$springVersion") + 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") @@ -99,4 +99,19 @@ tasks.named("test") { } } +// for hot-reload: +tasks.register("getDependencies") { + from(sourceSets.main.get().runtimeClasspath) + into("runtime/") + + doFirst { + val runtimeDir = File("runtime") + runtimeDir.deleteRecursively() + runtimeDir.mkdir() + } + + doLast { + File("runtime").deleteRecursively() + } +} diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 0d304fcc..c6f099b0 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -35,7 +35,5 @@ sentry.proxy.port=8090 sentry.traces-sample-rate=1.0 sentry.environment=production 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. +# hot reload: spring.devtools.livereload.enabled=true diff --git a/infra/configurations/backend/application-local.properties b/infra/configurations/backend/application-local.properties index 8ae3031c..905e873c 100644 --- a/infra/configurations/backend/application-local.properties +++ b/infra/configurations/backend/application-local.properties @@ -5,3 +5,5 @@ sentry.enabled=false sentry.dsn= sentry.traces-sample-rate=1.0 sentry.environment=localhost +# hot reload: +spring.devtools.livereload.enabled=true diff --git a/infra/docker/app/DockerfileLocalBack b/infra/docker/app/DockerfileLocalBack index 1b1f78b1..3ee87636 100644 --- a/infra/docker/app/DockerfileLocalBack +++ b/infra/docker/app/DockerfileLocalBack @@ -33,5 +33,5 @@ COPY infra/configurations/backend ./configurations/ EXPOSE 80 # Run the backend application -CMD ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=/tmp/backend/configurations/' +CMD (./gradlew -t :bootJar) & ./gradlew bootRun -PskipDownload=true --args='--spring.profiles.active=local --spring.config.additional-location=/tmp/backend/configurations/' From df2f13fd8ed5561c6a1521c69516b5d15cf16239 Mon Sep 17 00:00:00 2001 From: lwih Date: Mon, 11 Mar 2024 11:58:28 +0100 Subject: [PATCH 07/18] Docker-compose - comment metabase for now --- infra/docker-compose.local.yml | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml index 1e79c528..8740c419 100644 --- a/infra/docker-compose.local.yml +++ b/infra/docker-compose.local.yml @@ -36,25 +36,25 @@ services: volumes: - db:/var/lib/postgresql/data - metabase: - image: metabase/metabase:latest - ports: - - "3000:3000" - volumes: - - metabase_data:/metabase-data - environment: - # - MB_DB_CONNECTION_URI="db:5432/rapportnavdb?user=postgres&password=postgres" - - MB_DB_CONNECTION_URI=postgres://db:5432/rapportnavdb?currentSchema=metabase - - MB_DB_FILE=/metabase-data/metabase.db - - MB_DB_TYPE=postgres - # - MB_DB_DBNAME=rapportnavdb - # - MB_DB_PORT=5432 - - MB_DB_USER=postgres - - MB_DB_PASS=postgres - # - MB_DB_HOST=db - restart: always - depends_on: - - db +# metabase: +# image: metabase/metabase:latest +# ports: +# - "3000:3000" +# volumes: +# - metabase_data:/metabase-data +# environment: +# # - MB_DB_CONNECTION_URI="db:5432/rapportnavdb?user=postgres&password=postgres" +# - MB_DB_CONNECTION_URI=postgres://db:5432/rapportnavdb?currentSchema=metabase +# - MB_DB_FILE=/metabase-data/metabase.db +# - MB_DB_TYPE=postgres +# # - MB_DB_DBNAME=rapportnavdb +# # - MB_DB_PORT=5432 +# - MB_DB_USER=postgres +# - MB_DB_PASS=postgres +# # - MB_DB_HOST=db +# restart: always +# depends_on: +# - db volumes: db: From 90dc2c15db50a81ca622b7a03b6384fbbd278a1e Mon Sep 17 00:00:00 2001 From: lwih Date: Mon, 11 Mar 2024 19:46:10 +0100 Subject: [PATCH 08/18] Introduce import-meta-env for frontend --- frontend/.env.d.ts | 10 + frontend/.env.example | 5 + frontend/.env.local.defaults | 4 + frontend/.gitignore | 21 +- frontend/index.html | 9 + frontend/package-lock.json | 549 ++++++++++++++++++++++++++++++++- frontend/package.json | 7 +- frontend/src/apollo-client.ts | 5 +- frontend/src/index.tsx | 36 +-- frontend/src/sentry.ts | 36 +++ frontend/vite.config.ts | 10 +- infra/docker-compose.local.yml | 2 +- infra/docker/app/Dockerfile | 6 +- 13 files changed, 639 insertions(+), 61 deletions(-) create mode 100644 frontend/.env.d.ts create mode 100644 frontend/.env.example create mode 100644 frontend/.env.local.defaults create mode 100644 frontend/src/sentry.ts diff --git a/frontend/.env.d.ts b/frontend/.env.d.ts new file mode 100644 index 00000000..b5227674 --- /dev/null +++ b/frontend/.env.d.ts @@ -0,0 +1,10 @@ +// https://vitejs.dev/guide/env-and-mode#intellisense-for-typescript +/// + +interface ImportMetaEnv { + readonly FRONTEND_SENTRY_DSN: string +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/frontend/.env.example b/frontend/.env.example new file mode 100644 index 00000000..be9e9cdb --- /dev/null +++ b/frontend/.env.example @@ -0,0 +1,5 @@ + +################################################################################ +# Sentry + +FRONTEND_SENTRY_DSN=https://something@sentry.incubateur.net/121 diff --git a/frontend/.env.local.defaults b/frontend/.env.local.defaults new file mode 100644 index 00000000..4e2331c9 --- /dev/null +++ b/frontend/.env.local.defaults @@ -0,0 +1,4 @@ +################################################################################ +# Sentry + +FRONTEND_SENTRY_DSN=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 diff --git a/frontend/.gitignore b/frontend/.gitignore index c5892d75..e389ce6f 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -1,11 +1,24 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +# env .env +.env.local +.env.development +.env.development.local +.env.staging +.env.staging.local +.env.production +.env.production.local +.env.test +.env.test.local # dependencies /node_modules /.pnp .pnp.js +npm-debug.log* +yarn-debug.log* +yarn-error.log* # testing /coverage @@ -16,11 +29,3 @@ # misc .DS_Store -.env.local -.env.development.local -.env.test.local -.env.production.local - -npm-debug.log* -yarn-debug.log* -yarn-error.log* diff --git a/frontend/index.html b/frontend/index.html index 8aa9f95e..4559e5d9 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -9,7 +9,16 @@ +
+ + + + + + diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 7d261f9f..e1518c78 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -29,6 +29,9 @@ "web-vitals": "^2.1.4" }, "devDependencies": { + "@import-meta-env/cli": "^0.6.8", + "@import-meta-env/prepare": "0.1.13", + "@import-meta-env/unplugin": "^0.5.1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", @@ -2267,6 +2270,287 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/@import-meta-env/cli": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@import-meta-env/cli/-/cli-0.6.8.tgz", + "integrity": "sha512-Lunsmlj02yVtI5drlhNwIUFAQ0wsIUYIrz0Nm5jbvmYvyEUsxC8Qotnf3gXTfvM9Yuutvuc2+dx4uXpa3DajTg==", + "dev": true, + "dependencies": { + "commander": "11.1.0", + "glob": "10.3.10", + "picocolors": "1.0.0", + "serialize-javascript": "6.0.1" + }, + "bin": { + "import-meta-env": "bin/import-meta-env.js" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@import-meta-env/babel": "^0.4.3", + "@import-meta-env/swc": "^0.4.5", + "@import-meta-env/unplugin": "^0.4.8 || ^0.5.0", + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + }, + "peerDependenciesMeta": { + "@import-meta-env/babel": { + "optional": true + }, + "@import-meta-env/swc": { + "optional": true + }, + "@import-meta-env/unplugin": { + "optional": true + } + } + }, + "node_modules/@import-meta-env/cli/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@import-meta-env/cli/node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/@import-meta-env/cli/node_modules/glob": { + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/cli/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/prepare": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/@import-meta-env/prepare/-/prepare-0.1.13.tgz", + "integrity": "sha512-N/vu1JHcq4NX63/4d2sDWQaZFENtmoVDJNZwMib1MHiZPrkmuyoYj8sVBa/4wgc8f+lFXnliil4DBbI4w2aHzQ==", + "dev": true, + "dependencies": { + "commander": "11.1.0", + "glob": "10.3.10", + "picocolors": "1.0.0", + "serialize-javascript": "6.0.1" + }, + "bin": { + "import-meta-env-prepare": "bin/import-meta-env-prepare.js" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/commander": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz", + "integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==", + "dev": true, + "engines": { + "node": ">=16" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/glob": { + "version": "10.3.10", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", + "integrity": "sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.3.5", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/prepare/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@import-meta-env/unplugin": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@import-meta-env/unplugin/-/unplugin-0.5.1.tgz", + "integrity": "sha512-2pn+eYha02TY+iJ8WAlGr9SnOx0o+OvddO6lzU9hBxkogWlU9Q1dI/9thacnjL9alOA3R2qGZPd79kaiYtw81A==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "magic-string": "^0.30.0", + "object-hash": "^3.0.0", + "picocolors": "^1.0.0", + "unplugin": "^1.5.0" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@import-meta-env/cli": "^0.5.1 || ^0.6.0", + "dotenv": "^11.0.0 || ^12.0.4 || ^13.0.1 || ^14.3.2 || ^15.0.1 || ^16.0.0" + }, + "peerDependenciesMeta": { + "@import-meta-env/cli": { + "optional": true + } + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -3289,6 +3573,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@remix-run/router": { "version": "1.15.1", "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.15.1.tgz", @@ -5792,15 +6086,10 @@ } }, "node_modules/chokidar": { - "version": "3.5.3", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "license": "MIT", "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", @@ -5813,6 +6102,9 @@ "engines": { "node": ">= 8.10.0" }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, "optionalDependencies": { "fsevents": "~2.3.2" } @@ -6790,6 +7082,25 @@ "tslib": "^2.0.3" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "dev": true, + "peer": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, "node_modules/ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -8063,6 +8374,34 @@ "is-callable": "^1.1.3" } }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -9331,6 +9670,24 @@ "set-function-name": "^2.0.1" } }, + "node_modules/jackspeak": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", + "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest/-/jest-29.7.0.tgz", @@ -12270,6 +12627,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.4.tgz", + "integrity": "sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/mlly": { "version": "1.5.0", "dev": true, @@ -12490,6 +12856,15 @@ "node": ">=0.10.0" } }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, "node_modules/object-inspect": { "version": "1.13.1", "license": "MIT", @@ -12885,6 +13260,31 @@ "dev": true, "license": "MIT" }, + "node_modules/path-scurry": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", + "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "dev": true, + "dependencies": { + "lru-cache": "^9.1.1 || ^10.0.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", + "dev": true, + "engines": { + "node": "14 || >=16.14" + } + }, "node_modules/path-to-regexp": { "version": "6.2.1", "dev": true, @@ -13229,6 +13629,15 @@ ], "license": "MIT" }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, "node_modules/react": { "version": "18.2.0", "license": "MIT", @@ -13793,6 +14202,15 @@ "semver": "bin/semver.js" } }, + "node_modules/serialize-javascript": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.1.tgz", + "integrity": "sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/set-function-length": { "version": "1.2.0", "license": "MIT", @@ -14118,6 +14536,27 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "node_modules/string-width/node_modules/emoji-regex": { "version": "8.0.0", "license": "MIT" @@ -14193,6 +14632,19 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "3.0.0", "dev": true, @@ -14689,6 +15141,21 @@ "node": ">= 4.0.0" } }, + "node_modules/unplugin": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.9.0.tgz", + "integrity": "sha512-14PslvMY3gNbXnQtNIRB566Q057L5Fe7f5LDEamxVi0QQVxoz5hrveBwwZLcKyHtZ09ysmipxRRj5Lv+BGz2Iw==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "chokidar": "^3.6.0", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.6.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/untildify": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", @@ -15322,6 +15789,21 @@ "node": ">=12" } }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.1.tgz", + "integrity": "sha512-poXpCylU7ExuvZK8z+On3kX+S8o/2dQ/SVYueKA0D4WEMXROXgY8Ez50/bQEUmvoSMMrWcrJqCHuhAbsiwg7Dg==", + "dev": true + }, "node_modules/whatwg-encoding": { "version": "2.0.0", "dev": true, @@ -15465,6 +15947,57 @@ "node": ">=8" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/wrap-ansi/node_modules/ansi-styles": { "version": "4.3.0", "license": "MIT", diff --git a/frontend/package.json b/frontend/package.json index f4d73c5b..a36e3f56 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,8 +7,8 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "vite", - "build": "vite build", + "dev": "import-meta-env-prepare -x ./.env.local.defaults && vite", + "build": "vite build && import-meta-env -x .env.example -p dist/index.html", "build:with-sourcemaps": "vite build --sourcemap", "tsc": "tsc", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10000", @@ -39,6 +39,9 @@ "web-vitals": "^2.1.4" }, "devDependencies": { + "@import-meta-env/cli": "^0.6.8", + "@import-meta-env/prepare": "0.1.13", + "@import-meta-env/unplugin": "^0.5.1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.4.3", diff --git a/frontend/src/apollo-client.ts b/frontend/src/apollo-client.ts index 09bdf00e..e46db3ea 100644 --- a/frontend/src/apollo-client.ts +++ b/frontend/src/apollo-client.ts @@ -7,8 +7,7 @@ import { ErrorResponse, onError } from "@apollo/client/link/error"; const authToken = new AuthToken() -if (true) { - // if (__DEV__) { +if (import.meta.env.DEV) { // Adds messages only in a dev environment loadDevMessages() loadErrorMessages() @@ -32,7 +31,7 @@ const authLink = setContext((_, {headers}) => { } }) -const errorLink = onError(({graphQLErrors, networkError, operation, forward}: ErrorResponse) => { +const errorLink = onError(({operation, forward}: ErrorResponse) => { const {response} = operation.getContext() if ([401, 403].indexOf(response.status) !== -1) { diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index c75aa813..38430a3a 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -2,45 +2,21 @@ import React from 'react' import ReactDOM from 'react-dom/client' // import reportWebVitals from './report-web-vitals' import App from './app' -import * as Sentry from '@sentry/react' -import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from 'react-router-dom' -import { HttpClient, CaptureConsole, Debug } from "@sentry/integrations"; +import initSentry from "./sentry.ts"; import 'react-toastify/dist/ReactToastify.css' import 'rsuite/dist/rsuite.min.css' import './assets/css/index.css' import '@mtes-mct/monitor-ui/assets/stylesheets/rsuite-override.css' -Sentry.init({ - dsn: 'https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121', - integrations: [ - new Sentry.BrowserTracing({ - // See docs for support of different versions of variation of react router - // https://docs.sentry.io/platforms/javascript/guides/react/configuration/integrations/react-router/ - routingInstrumentation: Sentry.reactRouterV6Instrumentation( - React.useEffect, - useLocation, - useNavigationType, - createRoutesFromChildren, - matchRoutes - ) - }), - new Sentry.Replay(), - new HttpClient(), - new Debug(), - new CaptureConsole(), - ], - replaysOnErrorSampleRate: 1.0, - replaysSessionSampleRate: 0.1, - tracesSampleRate: 1.0 -}) +// setup sentry before starting +initSentry() const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement) - root.render( - - - + + + ) // If you want to start measuring performance in your app, pass a function diff --git a/frontend/src/sentry.ts b/frontend/src/sentry.ts new file mode 100644 index 00000000..ee493183 --- /dev/null +++ b/frontend/src/sentry.ts @@ -0,0 +1,36 @@ +import { useEffect } from "react"; +import { init, reactRouterV6BrowserTracingIntegration, replayIntegration } from "@sentry/react"; +import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router-dom"; +import { captureConsoleIntegration, debugIntegration, httpClientIntegration } from "@sentry/integrations"; + +const initSentry = () => { + const FRONTEND_SENTRY_DSN = import.meta.env.FRONTEND_SENTRY_DSN + const viteMode = import.meta.env.MODE + const isDev = import.meta.env.DEV + const release = "rapportnav2@" + process.env.npm_package_version + + init({ + dsn: FRONTEND_SENTRY_DSN, + environment: viteMode, + enabled: !isDev, + release: release, + integrations: [ + reactRouterV6BrowserTracingIntegration({ + useEffect: useEffect, + useLocation, + useNavigationType, + createRoutesFromChildren, + matchRoutes, + }), + replayIntegration(), + httpClientIntegration(), + debugIntegration(), + captureConsoleIntegration(), + ], + replaysOnErrorSampleRate: 1.0, + replaysSessionSampleRate: 0.1, + tracesSampleRate: 1.0 + }) +} + +export default initSentry diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 7bc4dfdc..cf67844a 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,11 +1,7 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import eslint from 'vite-plugin-eslint'; -import dotenv from 'dotenv'; - -// if (process.env.NODE_ENV === 'development') { -// dotenv.config(); -// } +import importMetaEnv from '@import-meta-env/unplugin' // https://vitejs.dev/config/ export default defineConfig({ @@ -32,6 +28,10 @@ export default defineConfig({ plugins: [ react(), eslint(), + importMetaEnv.vite({ + env: './.env', + example: './.env.example' + }) ], server: { host: true, diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml index 8740c419..20379beb 100644 --- a/infra/docker-compose.local.yml +++ b/infra/docker-compose.local.yml @@ -1,5 +1,5 @@ version: '3.8' - +name: RapportNav2 services: backend: build: diff --git a/infra/docker/app/Dockerfile b/infra/docker/app/Dockerfile index 6bf0e5ac..51e56020 100644 --- a/infra/docker/app/Dockerfile +++ b/infra/docker/app/Dockerfile @@ -1,5 +1,5 @@ -FROM azul/zulu-openjdk-alpine:17.0.7-17.42.19 as build-all +FROM azul/zulu-openjdk-alpine:17.0.7-17.42.19 AS build-all WORKDIR /home/rapportnav @@ -31,6 +31,4 @@ RUN mkdir /home/rapportnav/logs # It must point to the front (React) files ENV STATIC_FILES_PATH=/home/rapportnav/public - -# CMD exec java -jar "/home/rapportnav/rapportnav-${VERSION}.jar" -CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active=$ENV_PROFILE -jar "/home/rapportnav/rapportnav-${VERSION}.jar" +CMD exec java -Dspring.config.additional-location="/home/rapportnav/configurations/" -Dspring.profiles.active="$ENV_PROFILE" -jar "/home/rapportnav/rapportnav-${VERSION}.jar" From d7c362492f776e14a59ea3c537da5b4479931fc5 Mon Sep 17 00:00:00 2001 From: lwih Date: Mon, 11 Mar 2024 20:09:31 +0100 Subject: [PATCH 09/18] Backend - cleanup env vars --- .../src/main/resources/application.properties | 57 ++++++++++++------- .../backend/application-dev.properties | 8 --- .../backend/application-local.properties | 19 +++++-- .../backend/application-prod.properties | 9 ++- 4 files changed, 56 insertions(+), 37 deletions(-) delete mode 100644 infra/configurations/backend/application-dev.properties diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index c6f099b0..42db4a16 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -1,39 +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://db:5432/rapportnavdb?user=postgres&password=postgres +spring.datasource.url=${spring.datasource.url} 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://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/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 +sentry.enabled=${sentry.enabled} +sentry.dsn=${sentry.dsn} +sentry.proxy.host=${sentry.proxy.host} +sentry.proxy.port=${sentry.proxy.port} +sentry.traces-sample-rate=${sentry.traces-sample-rate} +sentry.environment=${sentry.environment} sentry.use-git-commit-id-as-release=true -# hot reload: -spring.devtools.livereload.enabled=true + diff --git a/infra/configurations/backend/application-dev.properties b/infra/configurations/backend/application-dev.properties deleted file mode 100644 index 116f369f..00000000 --- a/infra/configurations/backend/application-dev.properties +++ /dev/null @@ -1,8 +0,0 @@ -env.db.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres -spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres -#Sentry -sentry.enabled=false -sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 -#sentry.exception-resolver-order=-2147483647 -sentry.traces-sample-rate=1.0 -sentry.environment=dev diff --git a/infra/configurations/backend/application-local.properties b/infra/configurations/backend/application-local.properties index 905e873c..b7e36519 100644 --- a/infra/configurations/backend/application-local.properties +++ b/infra/configurations/backend/application-local.properties @@ -1,9 +1,16 @@ -env.db.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres +################ +################ +# Spring spring.datasource.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres -#Sentry -sentry.enabled=false -sentry.dsn= -sentry.traces-sample-rate=1.0 -sentry.environment=localhost # hot reload: spring.devtools.livereload.enabled=true +################ +################ +# Sentry +sentry.enabled=false +sentry.dsn= +sentry.proxy.host= +sentry.proxy.port= +sentry.traces-sample-rate=0.0 +sentry.environment=local + diff --git a/infra/configurations/backend/application-prod.properties b/infra/configurations/backend/application-prod.properties index a15aa54e..58dc5cd8 100644 --- a/infra/configurations/backend/application-prod.properties +++ b/infra/configurations/backend/application-prod.properties @@ -1,10 +1,15 @@ -env.db.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres +################ +################ +# Spring spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&password=postgres +# hot reload +spring.devtools.livereload.enabled=false +################ +################ #Sentry sentry.enabled=true sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/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 From e9c667f7b5474527135ed7af02742b95cd2fbcc9 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 12 Mar 2024 15:58:56 +0100 Subject: [PATCH 10/18] Introduce Gitlab feature flags via Unleash --- frontend/package-lock.json | 27 +++++ frontend/package.json | 2 + frontend/src/app.tsx | 85 ++++++++------ frontend/src/pam/missions/missions.tsx | 146 +++++++++++++------------ frontend/src/sentry.ts | 3 +- infra/docker-compose.local.yml | 34 +++++- 6 files changed, 185 insertions(+), 112 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e1518c78..333a335c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -12,6 +12,7 @@ "@mtes-mct/monitor-ui": "^13.7.2", "@sentry/integrations": "^7.101.1", "@sentry/react": "^7.100.1", + "@unleash/proxy-client-react": "^4.2.2", "apollo3-cache-persist": "^0.14.1", "date-fns": "^2.30.0", "email-validator": "^2.0.4", @@ -25,6 +26,7 @@ "rsuite": "^5.53.2", "styled-components": "^5.3.11", "type-fest": "^4.10.2", + "unleash-proxy-client": "^3.3.1", "uuid": "^9.0.1", "web-vitals": "^2.1.4" }, @@ -4856,6 +4858,17 @@ "dev": true, "license": "ISC" }, + "node_modules/@unleash/proxy-client-react": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@unleash/proxy-client-react/-/proxy-client-react-4.2.2.tgz", + "integrity": "sha512-KRg1dAQfxLSBe8O2i6GIGDM+7HUdUu/ntREy+JeYbmJ2b6ApFtLX/wt+3T/CjrTYjwRlZKZYJDx5E4fRDOQqpQ==", + "engines": { + "node": ">=16.0.0" + }, + "peerDependencies": { + "unleash-proxy-client": "^3.2.0" + } + }, "node_modules/@vitejs/plugin-react": { "version": "4.2.1", "dev": true, @@ -14794,6 +14807,11 @@ "version": "2.3.8", "license": "MIT" }, + "node_modules/tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" + }, "node_modules/tiny-warning": { "version": "1.0.3", "license": "MIT" @@ -15141,6 +15159,15 @@ "node": ">= 4.0.0" } }, + "node_modules/unleash-proxy-client": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/unleash-proxy-client/-/unleash-proxy-client-3.3.1.tgz", + "integrity": "sha512-tekoTRWBK+B0uG9o/5CJ+LAKNZv+OdLPFVXFESQU2JHnyjtedLyTAmdWhPIxC/eCKiBBay1/2BEWOUCJaL1vzQ==", + "dependencies": { + "tiny-emitter": "^2.1.0", + "uuid": "^9.0.1" + } + }, "node_modules/unplugin": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.9.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index a36e3f56..e34356e7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,6 +22,7 @@ "@mtes-mct/monitor-ui": "^13.7.2", "@sentry/integrations": "^7.101.1", "@sentry/react": "^7.100.1", + "@unleash/proxy-client-react": "^4.2.2", "apollo3-cache-persist": "^0.14.1", "date-fns": "^2.30.0", "email-validator": "^2.0.4", @@ -35,6 +36,7 @@ "rsuite": "^5.53.2", "styled-components": "^5.3.11", "type-fest": "^4.10.2", + "unleash-proxy-client": "^3.3.1", "uuid": "^9.0.1", "web-vitals": "^2.1.4" }, diff --git a/frontend/src/app.tsx b/frontend/src/app.tsx index 4be53fdc..8bbf7b79 100644 --- a/frontend/src/app.tsx +++ b/frontend/src/app.tsx @@ -8,46 +8,59 @@ import RouterProvider from './router/router-provider' import * as Sentry from "@sentry/react"; import ErrorPage from "./error-page.tsx"; import { Notifier } from "@mtes-mct/monitor-ui"; +import { FlagProvider } from '@unleash/proxy-client-react'; +import { IConfig } from "unleash-proxy-client"; + + +const config: IConfig = { + url: 'http://localhost:3000/proxy', // Your front-end API URL or the Unleash proxy's URL (https:///proxy) + clientKey: 'randomkey', // A client-side API token OR one of your proxy's designated client keys (previously known as proxy secrets) + refreshInterval: 60, // How often (in seconds) the client should poll the proxy for updates + appName: 'rapportnav2-flags', // The name of your application. It's only used for identifying your application + environment: 'local', +}; const App: FC = () => { - const [loading, setLoading] = useState(true) - const [client, setClient] = useState>(apolloClient) - - useEffect(() => { - async function init() { - const cache = apolloCache - let newPersistor = new CachePersistor({ - cache, - storage: new LocalStorageWrapper(window.localStorage), - debug: true - // trigger: 'write' - }) - - await newPersistor.restore() - // setPersistor(newPersistor); - setClient(apolloClient) - - setLoading(false) // Set loading to false after cache is restored + const [loading, setLoading] = useState(true) + const [client, setClient] = useState>(apolloClient) + + useEffect(() => { + async function init() { + const cache = apolloCache + let newPersistor = new CachePersistor({ + cache, + storage: new LocalStorageWrapper(window.localStorage), + debug: true + // trigger: 'write' + }) + + await newPersistor.restore() + // setPersistor(newPersistor); + setClient(apolloClient) + + setLoading(false) // Set loading to false after cache is restored + } + + init().catch(console.error) + }, []) + + if (loading) { + // Render a loading indicator or anything you like + return
Chargement...
} - init().catch(console.error) - }, []) - - if (loading) { - // Render a loading indicator or anything you like - return
Chargement...
- } - - return ( - - - - - - - - - ) + return ( + + + + + + + + + + + ) } export default Sentry.withProfiler(App); diff --git a/frontend/src/pam/missions/missions.tsx b/frontend/src/pam/missions/missions.tsx index a203ae98..44fe4bd5 100644 --- a/frontend/src/pam/missions/missions.tsx +++ b/frontend/src/pam/missions/missions.tsx @@ -6,88 +6,92 @@ import { Link } from 'react-router-dom' import Text from "../../ui/text.tsx"; import useMissions from "./use-missions.tsx"; import { GET_MISSION_BY_ID } from "../mission/use-mission-by-id.tsx"; +import { useFlag } from "@unleash/proxy-client-react"; const Missions: React.FC = () => { - const {loading, data: missions, error, client} = useMissions() + const {loading, data: missions, error, client} = useMissions() - const prefetchMission = async (missionId: string) => { - await client.query({ - query: GET_MISSION_BY_ID, - variables: {missionId} - }) - } + const export_rapport = useFlag('export_rapport'); + console.log('export_rapport enabled: ', export_rapport) - if (loading) { - return ( - Missions en cours de chargement}/> - ) - } + const prefetchMission = async (missionId: string) => { + await client.query({ + query: GET_MISSION_BY_ID, + variables: {missionId} + }) + } - if (error) { - return ( - - - - - Une erreur s'est produite lors du chargement de vos missions. Si le problème - persiste, - veuillez contacter l'équipe RapportNav. - - - Erreur: {error?.message} - - - - - ) - } + if (loading) { + return ( + Missions en cours de chargement}/> + ) + } - if (missions) { - return ( - - - - -

Missions

-
+ if (error) { + return ( + + + + + Une erreur s'est produite lors du chargement de vos missions. Si le problème + persiste, + veuillez contacter l'équipe RapportNav. + + + Erreur: {error?.message} + + + + + ) + } - -

Mes rapports de mission

-
+ if (missions) { + return ( + + + + +

Missions

+
- - - - - + +

Mes rapports de mission

+
- - {loading ? ( - - - - - - ) : ( - - )} - -
-
-
- ) - } + + + + + - return null + + {loading ? ( + + + + + + ) : ( + + )} + +
+
+
+ ) + } + + return null } export default Missions diff --git a/frontend/src/sentry.ts b/frontend/src/sentry.ts index ee493183..9b592850 100644 --- a/frontend/src/sentry.ts +++ b/frontend/src/sentry.ts @@ -7,7 +7,8 @@ const initSentry = () => { const FRONTEND_SENTRY_DSN = import.meta.env.FRONTEND_SENTRY_DSN const viteMode = import.meta.env.MODE const isDev = import.meta.env.DEV - const release = "rapportnav2@" + process.env.npm_package_version + // const release = "rapportnav2@" + process.env.npm_package_version + const release = "rapportnav2@" + "1" init({ dsn: FRONTEND_SENTRY_DSN, diff --git a/infra/docker-compose.local.yml b/infra/docker-compose.local.yml index 20379beb..a562ded5 100644 --- a/infra/docker-compose.local.yml +++ b/infra/docker-compose.local.yml @@ -1,10 +1,10 @@ version: '3.8' -name: RapportNav2 +name: rapportnav2 services: backend: build: context: .. - dockerfile: docker/app/DockerfileLocalBack + dockerfile: ./infra/docker/app/DockerfileLocalBack ports: - "80:80" depends_on: @@ -19,7 +19,7 @@ services: frontend: build: context: ../frontend - dockerfile: docker/app/DockerfileLocalFront + dockerfile: ../infra/docker/app/DockerfileLocalFront ports: - "5173:5173" volumes: @@ -36,6 +36,32 @@ services: volumes: - db:/var/lib/postgresql/data + unleash_proxy: + image: unleashorg/unleash-proxy:v1.1.1 + ports: + - "3000:3000" + environment: + # Proxy clients must use one of these keys to connect to the + # Proxy. To add more keys, separate them with a comma (`key1,key2`). + # UNLEASH_PROXY_CLIENT_KEYS: "randomkey" + UNLEASH_PROXY_SECRETS: "randomkey" + UNLEASH_APP_NAME: "local" + # This points the Proxy to the Unleash server API + UNLEASH_URL: "https://gitlab.com/api/v4/feature_flags/unleash/55951570" + UNLEASH_INSTANCE_ID: "glffct-ceHLxPcFMqyXsyGPXSkx" + # This is the API token that the Proxy uses to communicate with + # the Unleash server. + UNLEASH_API_TOKEN: "glpat-6f7PUWe9PwRoa53LUmsZ" + ENABLE_ALL_ENDPOINT: true + LOG_LEVEL: "debug" + # depends_on: + # - web + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:3000/proxy/health || exit 1 + interval: 1s + timeout: 1m + retries: 5 + # metabase: # image: metabase/metabase:latest # ports: @@ -59,4 +85,4 @@ services: volumes: db: name: rapportnavdb - metabase_data: +# metabase_data: From 8b38d2a42898b8f9310a2f92f17653f432bfeb69 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 15:25:39 +0100 Subject: [PATCH 11/18] Backend - gitignore and delete target/ --- backend/.gitignore | 1 + backend/target/classes/application.properties | 33 --- ...__alter_mission_action_control_lat_lon.sql | 6 - .../V0.11__alter_controls_add_delete_at.sql | 17 -- .../V0.12__alter_status_add_delete_at.sql | 5 - .../V0.13__delete_crew_and_crew_role.sql | 8 - .../V0.14__alter_controls_change_format.sql | 77 ------ ..._alter_action_controls_remove_not_null.sql | 19 -- ..._drop_fk_on_controls_to_action_control.sql | 14 - .../db/migration/V0.17__alter_controls.sql | 69 ----- .../V0.1__create_crew_role_table.sql | 5 - .../db/migration/V0.2__insert_crew_role.sql | 5 - .../db/migration/V0.3__create_crew_table.sql | 6 - .../db/migration/V0.4__insert_crew.sql | 11 - .../db/migration/V0.5__create_user_table.sql | 6 - .../migration/V0.6__add_metabase_schema.sql | 6 - ...0.7__add_mission_action_control_schema.sql | 17 -- .../migration/V0.8__add_control_schemas.sql | 53 ---- .../V0.9__add_action_status_schema.sql | 18 -- .../V1.2023.10.30.15.30__test_dummy.sql | 6 - .../V1.2023.10.30.16.30__remove_dummy.sql | 1 - ...0.18.30__alter_controls_ref_key_format.sql | 83 ------ ....11.01.18.30__create_infraction_tables.sql | 28 -- ....18.30__alter_infraction_add_deletedat.sql | 5 - ...1.06.20.30__alter_remove_all_deletedat.sql | 20 -- ....19.30__alter_infractions_add_actionid.sql | 5 - ...23.11.07.20.30__create_env_infractions.sql | 19 -- ...0__alter_infraction_field_formalnotice.sql | 5 - ...1.2023.11.08.20.54__create_crew_tables.sql | 35 --- ...alter_table_service_add_service_linked.sql | 5 - ....30__create_mission_general_info_table.sql | 12 - ...2023.11.27__drop_agent_crew_constraint.sql | 2 - ...11.28.14.30__update_user_link_to_agent.sql | 11 - ...V1.2023.11.28.20.54__alter_crew_tables.sql | 12 - ...V1.2023.11.29.10.54__alter_user_tables.sql | 18 -- .../V1.2023.12.04.10.54__add_agent_roles.sql | 14 - .../V1.2023.12.04.11.34__add_services.sql | 13 - .../V1.2023.12.04.11.44__add_agents.sql | 85 ------ ...23.12.04.11.55__add_agent_service_link.sql | 90 ------- .../target/classes/graphql/action.graphqls | 243 ------------------ .../target/classes/graphql/controls.graphqls | 118 --------- backend/target/classes/graphql/crew.graphqls | 55 ---- .../classes/graphql/infraction.graphqls | 72 ------ .../target/classes/graphql/mission.graphqls | 41 --- backend/target/classes/graphql/user.graphqls | 6 - 45 files changed, 1 insertion(+), 1379 deletions(-) delete mode 100644 backend/target/classes/application.properties delete mode 100644 backend/target/classes/db/migration/V0.10__alter_mission_action_control_lat_lon.sql delete mode 100644 backend/target/classes/db/migration/V0.11__alter_controls_add_delete_at.sql delete mode 100644 backend/target/classes/db/migration/V0.12__alter_status_add_delete_at.sql delete mode 100644 backend/target/classes/db/migration/V0.13__delete_crew_and_crew_role.sql delete mode 100644 backend/target/classes/db/migration/V0.14__alter_controls_change_format.sql delete mode 100644 backend/target/classes/db/migration/V0.15__alter_action_controls_remove_not_null.sql delete mode 100644 backend/target/classes/db/migration/V0.16__drop_fk_on_controls_to_action_control.sql delete mode 100644 backend/target/classes/db/migration/V0.17__alter_controls.sql delete mode 100644 backend/target/classes/db/migration/V0.1__create_crew_role_table.sql delete mode 100644 backend/target/classes/db/migration/V0.2__insert_crew_role.sql delete mode 100644 backend/target/classes/db/migration/V0.3__create_crew_table.sql delete mode 100644 backend/target/classes/db/migration/V0.4__insert_crew.sql delete mode 100644 backend/target/classes/db/migration/V0.5__create_user_table.sql delete mode 100644 backend/target/classes/db/migration/V0.6__add_metabase_schema.sql delete mode 100644 backend/target/classes/db/migration/V0.7__add_mission_action_control_schema.sql delete mode 100644 backend/target/classes/db/migration/V0.8__add_control_schemas.sql delete mode 100644 backend/target/classes/db/migration/V0.9__add_action_status_schema.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.10.30.15.30__test_dummy.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.10.30.16.30__remove_dummy.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.10.30.18.30__alter_controls_ref_key_format.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.01.18.30__create_infraction_tables.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.06.18.30__alter_infraction_add_deletedat.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.06.20.30__alter_remove_all_deletedat.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.07.19.30__alter_infractions_add_actionid.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.07.20.30__create_env_infractions.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.08.17.30__alter_infraction_field_formalnotice.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.08.20.54__create_crew_tables.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.15.11.09.40__alter_table_service_add_service_linked.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.15.19.30__create_mission_general_info_table.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.27__drop_agent_crew_constraint.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.28.14.30__update_user_link_to_agent.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.28.20.54__alter_crew_tables.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.11.29.10.54__alter_user_tables.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.12.04.10.54__add_agent_roles.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.12.04.11.34__add_services.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.12.04.11.44__add_agents.sql delete mode 100644 backend/target/classes/db/migration/V1.2023.12.04.11.55__add_agent_service_link.sql delete mode 100644 backend/target/classes/graphql/action.graphqls delete mode 100644 backend/target/classes/graphql/controls.graphqls delete mode 100644 backend/target/classes/graphql/crew.graphqls delete mode 100644 backend/target/classes/graphql/infraction.graphqls delete mode 100644 backend/target/classes/graphql/mission.graphqls delete mode 100644 backend/target/classes/graphql/user.graphqls diff --git a/backend/.gitignore b/backend/.gitignore index c03be1d1..58a27f9a 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -3,6 +3,7 @@ HELP.md ### Gradle ### .gradle build/ +target/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ diff --git a/backend/target/classes/application.properties b/backend/target/classes/application.properties deleted file mode 100644 index 27080bfe..00000000 --- a/backend/target/classes/application.properties +++ /dev/null @@ -1,33 +0,0 @@ -# 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.mvc.static-path-pattern=/** -spring.web.resources.static-locations=file:${STATIC_FILES_PATH} - -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.driver-class-name=org.postgresql.Driver - -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 - - -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 diff --git a/backend/target/classes/db/migration/V0.10__alter_mission_action_control_lat_lon.sql b/backend/target/classes/db/migration/V0.10__alter_mission_action_control_lat_lon.sql deleted file mode 100644 index 0cf00847..00000000 --- a/backend/target/classes/db/migration/V0.10__alter_mission_action_control_lat_lon.sql +++ /dev/null @@ -1,6 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE mission_action_control - ADD COLUMN latitude DOUBLE PRECISION, - ADD COLUMN longitude DOUBLE PRECISION; -END $$; diff --git a/backend/target/classes/db/migration/V0.11__alter_controls_add_delete_at.sql b/backend/target/classes/db/migration/V0.11__alter_controls_add_delete_at.sql deleted file mode 100644 index 984d9850..00000000 --- a/backend/target/classes/db/migration/V0.11__alter_controls_add_delete_at.sql +++ /dev/null @@ -1,17 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE mission_action_control - ADD COLUMN deleted_at TIMESTAMP; - - ALTER TABLE control_gens_de_mer - ADD COLUMN deleted_at TIMESTAMP; - - ALTER TABLE control_security - ADD COLUMN deleted_at TIMESTAMP; - - ALTER TABLE control_navigation - ADD COLUMN deleted_at TIMESTAMP; - - ALTER TABLE control_administrative - ADD COLUMN deleted_at TIMESTAMP; -END $$; diff --git a/backend/target/classes/db/migration/V0.12__alter_status_add_delete_at.sql b/backend/target/classes/db/migration/V0.12__alter_status_add_delete_at.sql deleted file mode 100644 index c2a29885..00000000 --- a/backend/target/classes/db/migration/V0.12__alter_status_add_delete_at.sql +++ /dev/null @@ -1,5 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE mission_action_status - ADD COLUMN deleted_at TIMESTAMP; -END $$; diff --git a/backend/target/classes/db/migration/V0.13__delete_crew_and_crew_role.sql b/backend/target/classes/db/migration/V0.13__delete_crew_and_crew_role.sql deleted file mode 100644 index 385d2a58..00000000 --- a/backend/target/classes/db/migration/V0.13__delete_crew_and_crew_role.sql +++ /dev/null @@ -1,8 +0,0 @@ -DO $$ -BEGIN - -- Delete the crew table - DROP TABLE IF EXISTS crew; - - -- Delete the crew_role table - DROP TABLE IF EXISTS crew_role; -END $$; diff --git a/backend/target/classes/db/migration/V0.14__alter_controls_change_format.sql b/backend/target/classes/db/migration/V0.14__alter_controls_change_format.sql deleted file mode 100644 index e2374d2c..00000000 --- a/backend/target/classes/db/migration/V0.14__alter_controls_change_format.sql +++ /dev/null @@ -1,77 +0,0 @@ -DO $$ -BEGIN - -- Modify control_gens_de_mer table - ALTER TABLE control_gens_de_mer - ADD COLUMN staff_outnumbered_text VARCHAR(16); - - ALTER TABLE control_gens_de_mer - ADD COLUMN up_to_date_medical_check_text VARCHAR(16); - - ALTER TABLE control_gens_de_mer - ADD COLUMN knowledge_of_french_law_and_language_text VARCHAR(16); -END $$; - -DO $$ -BEGIN - -- Drop columns in control_gens_de_mer - ALTER TABLE control_gens_de_mer - DROP COLUMN staff_outnumbered; - - ALTER TABLE control_gens_de_mer - DROP COLUMN up_to_date_medical_check; - - ALTER TABLE control_gens_de_mer - DROP COLUMN knowledge_of_french_law_and_language; -END $$; - -DO $$ -BEGIN - -- Rename columns in control_gens_de_mer - ALTER TABLE control_gens_de_mer - RENAME COLUMN staff_outnumbered_text TO staff_outnumbered; - - ALTER TABLE control_gens_de_mer - RENAME COLUMN up_to_date_medical_check_text TO up_to_date_medical_check; - - ALTER TABLE control_gens_de_mer - RENAME COLUMN knowledge_of_french_law_and_language_text TO knowledge_of_french_law_and_language; -END $$; - -DO $$ -BEGIN - -- Modify control_administrative table - ALTER TABLE control_administrative - ADD COLUMN compliant_operating_permit_text VARCHAR(16); - - ALTER TABLE control_administrative - ADD COLUMN up_to_date_navigation_permit_text VARCHAR(16); - - ALTER TABLE control_administrative - ADD COLUMN compliant_security_documents_text VARCHAR(16); -END $$; - -DO $$ -BEGIN - -- Drop columns in control_administrative - ALTER TABLE control_administrative - DROP COLUMN compliant_operating_permit; - - ALTER TABLE control_administrative - DROP COLUMN up_to_date_navigation_permit; - - ALTER TABLE control_administrative - DROP COLUMN compliant_security_documents; -END $$; - -DO $$ -BEGIN - -- Rename columns in control_administrative - ALTER TABLE control_administrative - RENAME COLUMN compliant_operating_permit_text TO compliant_operating_permit; - - ALTER TABLE control_administrative - RENAME COLUMN up_to_date_navigation_permit_text TO up_to_date_navigation_permit; - - ALTER TABLE control_administrative - RENAME COLUMN compliant_security_documents_text TO compliant_security_documents; -END $$; diff --git a/backend/target/classes/db/migration/V0.15__alter_action_controls_remove_not_null.sql b/backend/target/classes/db/migration/V0.15__alter_action_controls_remove_not_null.sql deleted file mode 100644 index d68cf1fe..00000000 --- a/backend/target/classes/db/migration/V0.15__alter_action_controls_remove_not_null.sql +++ /dev/null @@ -1,19 +0,0 @@ -DO $$ -BEGIN - -- For the vessel_identifier column - ALTER TABLE mission_action_control - ALTER COLUMN vessel_identifier DROP NOT NULL; - - -- For the vessel_type column - ALTER TABLE mission_action_control - ALTER COLUMN vessel_type DROP NOT NULL; - - -- For the vessel_size column - ALTER TABLE mission_action_control - ALTER COLUMN vessel_size DROP NOT NULL; - - -- For the identity_controlled_person column - ALTER TABLE mission_action_control - ALTER COLUMN identity_controlled_person DROP NOT NULL; - -END $$; diff --git a/backend/target/classes/db/migration/V0.16__drop_fk_on_controls_to_action_control.sql b/backend/target/classes/db/migration/V0.16__drop_fk_on_controls_to_action_control.sql deleted file mode 100644 index 91c48433..00000000 --- a/backend/target/classes/db/migration/V0.16__drop_fk_on_controls_to_action_control.sql +++ /dev/null @@ -1,14 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE control_gens_de_mer - DROP CONSTRAINT fk_control_gens_de_mer_action_id; - - ALTER TABLE control_security - DROP CONSTRAINT fk_control_security_action_id; - - ALTER TABLE control_navigation - DROP CONSTRAINT fk_control_navigation_action_id; - - ALTER TABLE control_administrative - DROP CONSTRAINT fk_control_administrative_action_id; -END $$; diff --git a/backend/target/classes/db/migration/V0.17__alter_controls.sql b/backend/target/classes/db/migration/V0.17__alter_controls.sql deleted file mode 100644 index 83cf62d4..00000000 --- a/backend/target/classes/db/migration/V0.17__alter_controls.sql +++ /dev/null @@ -1,69 +0,0 @@ -DO $$ -BEGIN - - -- 1. Drop the 'confirmed' column - ALTER TABLE control_administrative - DROP COLUMN confirmed; - - -- 2. Add the 'unit_should_confirm' boolean column - ALTER TABLE control_administrative - ADD COLUMN unit_should_confirm BOOLEAN; - - -- 3. Add the 'unit_has_confirmed' boolean column - ALTER TABLE control_administrative - ADD COLUMN unit_has_confirmed BOOLEAN; - - -- 4. Add the 'amount_of_controls' integer column - ALTER TABLE control_administrative - ADD COLUMN amount_of_controls INT DEFAULT 1 NOT NULL; - - ------------------------------------------------------------------- - -- 1. Drop the 'confirmed' column - ALTER TABLE control_navigation - DROP COLUMN confirmed; - - -- 2. Add the 'unit_should_confirm' boolean column - ALTER TABLE control_navigation - ADD COLUMN unit_should_confirm BOOLEAN; - - -- 3. Add the 'unit_has_confirmed' boolean column - ALTER TABLE control_navigation - ADD COLUMN unit_has_confirmed BOOLEAN; - - -- 4. Add the 'amount_of_controls' integer column - ALTER TABLE control_navigation - ADD COLUMN amount_of_controls INT DEFAULT 1 NOT NULL; - ------------------------------------------------------------------- - -- 1. Drop the 'confirmed' column - ALTER TABLE control_security - DROP COLUMN confirmed; - - -- 2. Add the 'unit_should_confirm' boolean column - ALTER TABLE control_security - ADD COLUMN unit_should_confirm BOOLEAN; - - -- 3. Add the 'unit_has_confirmed' boolean column - ALTER TABLE control_security - ADD COLUMN unit_has_confirmed BOOLEAN; - - -- 4. Add the 'amount_of_controls' integer column - ALTER TABLE control_security - ADD COLUMN amount_of_controls INT DEFAULT 1 NOT NULL; - ------------------------------------------------------------------- - -- 1. Drop the 'confirmed' column - ALTER TABLE control_gens_de_mer - DROP COLUMN confirmed; - - -- 2. Add the 'unit_should_confirm' boolean column - ALTER TABLE control_gens_de_mer - ADD COLUMN unit_should_confirm BOOLEAN; - - -- 3. Add the 'unit_has_confirmed' boolean column - ALTER TABLE control_gens_de_mer - ADD COLUMN unit_has_confirmed BOOLEAN; - - -- 4. Add the 'amount_of_controls' integer column - ALTER TABLE control_gens_de_mer - ADD COLUMN amount_of_controls INT DEFAULT 1 NOT NULL; - -END $$; diff --git a/backend/target/classes/db/migration/V0.1__create_crew_role_table.sql b/backend/target/classes/db/migration/V0.1__create_crew_role_table.sql deleted file mode 100644 index 8890f4cc..00000000 --- a/backend/target/classes/db/migration/V0.1__create_crew_role_table.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE public.crew_role ( - role VARCHAR(64) NOT NULL, - is_archived BOOLEAN NOT NULL -); - diff --git a/backend/target/classes/db/migration/V0.2__insert_crew_role.sql b/backend/target/classes/db/migration/V0.2__insert_crew_role.sql deleted file mode 100644 index ddcdb40b..00000000 --- a/backend/target/classes/db/migration/V0.2__insert_crew_role.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO public.crew_role (role, is_archived) VALUES -('Commandant', false), -('Agent de pont', false), -('Non précisé', false), -('Chef cuisinier', false); \ No newline at end of file diff --git a/backend/target/classes/db/migration/V0.3__create_crew_table.sql b/backend/target/classes/db/migration/V0.3__create_crew_table.sql deleted file mode 100644 index 148f7e32..00000000 --- a/backend/target/classes/db/migration/V0.3__create_crew_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE public.crew ( - id SERIAL PRIMARY KEY, - first_name VARCHAR(64) NOT NULL, - last_name VARCHAR(64) NOT NULL, - is_archived BOOLEAN NOT NULL -); diff --git a/backend/target/classes/db/migration/V0.4__insert_crew.sql b/backend/target/classes/db/migration/V0.4__insert_crew.sql deleted file mode 100644 index d5533466..00000000 --- a/backend/target/classes/db/migration/V0.4__insert_crew.sql +++ /dev/null @@ -1,11 +0,0 @@ -INSERT INTO public.crew (first_name, last_name, is_archived) VALUES -('Antoine', 'Dupont', false), -('Julie', 'Martin', false), -('Lucas', 'Dubois', false), -('Emma', 'Bernard', false), -('Hugo', 'Thomas', false), -('Chloé', 'Robert', false), -('Louis', 'Richard', false), -('Léa', 'Petit', false), -('Adam', 'Durand', false), -('Camille', 'Leroy', false); diff --git a/backend/target/classes/db/migration/V0.5__create_user_table.sql b/backend/target/classes/db/migration/V0.5__create_user_table.sql deleted file mode 100644 index da9ee2ad..00000000 --- a/backend/target/classes/db/migration/V0.5__create_user_table.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE "user" ( - id SERIAL PRIMARY KEY, - name VARCHAR NOT NULL, - email VARCHAR UNIQUE NOT NULL, - password VARCHAR NOT NULL -); diff --git a/backend/target/classes/db/migration/V0.6__add_metabase_schema.sql b/backend/target/classes/db/migration/V0.6__add_metabase_schema.sql deleted file mode 100644 index dabd9b4d..00000000 --- a/backend/target/classes/db/migration/V0.6__add_metabase_schema.sql +++ /dev/null @@ -1,6 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.schemata WHERE schema_name = 'metabase') THEN - CREATE SCHEMA metabase; - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V0.7__add_mission_action_control_schema.sql b/backend/target/classes/db/migration/V0.7__add_mission_action_control_schema.sql deleted file mode 100644 index 5549ddf0..00000000 --- a/backend/target/classes/db/migration/V0.7__add_mission_action_control_schema.sql +++ /dev/null @@ -1,17 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'mission_action_control') THEN - CREATE TABLE mission_action_control ( - id UUID PRIMARY KEY, - mission_id INT NOT NULL, - start_datetime_utc TIMESTAMP NOT NULL, - end_datetime_utc TIMESTAMP, - control_method VARCHAR(16) NOT NULL, - vessel_identifier VARCHAR(64) NOT NULL, - vessel_type VARCHAR(32) NOT NULL, - vessel_size VARCHAR(32) NOT NULL, - identity_controlled_person VARCHAR(128) NOT NULL, - observations TEXT - ); - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V0.8__add_control_schemas.sql b/backend/target/classes/db/migration/V0.8__add_control_schemas.sql deleted file mode 100644 index c38e0327..00000000 --- a/backend/target/classes/db/migration/V0.8__add_control_schemas.sql +++ /dev/null @@ -1,53 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'control_gens_de_mer') THEN - CREATE TABLE control_gens_de_mer ( - id UUID PRIMARY KEY, - mission_id INT NOT NULL, - action_control_id UUID NOT NULL, - confirmed BOOLEAN, - staff_outnumbered BOOLEAN, - up_to_date_medical_check BOOLEAN, - knowledge_of_french_law_and_language BOOLEAN, - observations TEXT, - CONSTRAINT fk_control_gens_de_mer_action_id FOREIGN KEY (action_control_id) REFERENCES mission_action_control(id) - ); - END IF; - - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'control_security') THEN - CREATE TABLE control_security ( - id UUID PRIMARY KEY, - mission_id INT NOT NULL, - action_control_id UUID NOT NULL, - confirmed BOOLEAN, - observations TEXT, - CONSTRAINT fk_control_security_action_id FOREIGN KEY (action_control_id) REFERENCES mission_action_control(id) - ); - END IF; - - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'control_navigation') THEN - CREATE TABLE control_navigation ( - id UUID PRIMARY KEY, - mission_id INT NOT NULL, - action_control_id UUID NOT NULL, - confirmed BOOLEAN, - observations TEXT, - CONSTRAINT fk_control_navigation_action_id FOREIGN KEY (action_control_id) REFERENCES mission_action_control(id) - ); - END IF; - - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'control_administrative') THEN - CREATE TABLE control_administrative ( - id UUID PRIMARY KEY, - mission_id INT NOT NULL, - action_control_id UUID NOT NULL, - confirmed BOOLEAN, - compliant_operating_permit BOOLEAN, - up_to_date_navigation_permit BOOLEAN, - compliant_security_documents BOOLEAN, - observations TEXT, - CONSTRAINT fk_control_administrative_action_id FOREIGN KEY (action_control_id) REFERENCES mission_action_control(id) - ); - END IF; - -END $$; diff --git a/backend/target/classes/db/migration/V0.9__add_action_status_schema.sql b/backend/target/classes/db/migration/V0.9__add_action_status_schema.sql deleted file mode 100644 index 81e3a861..00000000 --- a/backend/target/classes/db/migration/V0.9__add_action_status_schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.tables - WHERE table_name = 'mission_action_status' - ) THEN - CREATE TABLE mission_action_status ( - id UUID PRIMARY KEY, - mission_id INTEGER NOT NULL, - start_datetime_utc TIMESTAMP NOT NULL, - is_start BOOLEAN NOT NULL, - status VARCHAR(64) NOT NULL, - reason VARCHAR(64), - observations TEXT - ); - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.10.30.15.30__test_dummy.sql b/backend/target/classes/db/migration/V1.2023.10.30.15.30__test_dummy.sql deleted file mode 100644 index 335c73a1..00000000 --- a/backend/target/classes/db/migration/V1.2023.10.30.15.30__test_dummy.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE public.dummy ( - id SERIAL PRIMARY KEY, - first_name VARCHAR(64) NOT NULL, - last_name VARCHAR(64) NOT NULL, - is_archived BOOLEAN NOT NULL -); diff --git a/backend/target/classes/db/migration/V1.2023.10.30.16.30__remove_dummy.sql b/backend/target/classes/db/migration/V1.2023.10.30.16.30__remove_dummy.sql deleted file mode 100644 index 314d155a..00000000 --- a/backend/target/classes/db/migration/V1.2023.10.30.16.30__remove_dummy.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS dummy; diff --git a/backend/target/classes/db/migration/V1.2023.10.30.18.30__alter_controls_ref_key_format.sql b/backend/target/classes/db/migration/V1.2023.10.30.18.30__alter_controls_ref_key_format.sql deleted file mode 100644 index 0258e563..00000000 --- a/backend/target/classes/db/migration/V1.2023.10.30.18.30__alter_controls_ref_key_format.sql +++ /dev/null @@ -1,83 +0,0 @@ -DO $$ -BEGIN - -- Change the data type of action_control_id from UUID to VARCHAR(36) - - -- First, create a new temporary column with the desired data type - ALTER TABLE control_security - ADD COLUMN action_control_id_temp VARCHAR(36); - - -- Update the temporary column with data from the original UUID column - UPDATE control_security - SET action_control_id_temp = action_control_id::VARCHAR; - - -- Drop the original UUID column - ALTER TABLE control_security - DROP COLUMN action_control_id; - - -- Rename the temporary column to action_control_id - ALTER TABLE control_security - RENAME COLUMN action_control_id_temp TO action_control_id; -END $$; - -DO $$ -BEGIN - -- Change the data type of action_control_id from UUID to VARCHAR(36) - - -- First, create a new temporary column with the desired data type - ALTER TABLE control_administrative - ADD COLUMN action_control_id_temp VARCHAR(36); - - -- Update the temporary column with data from the original UUID column - UPDATE control_administrative - SET action_control_id_temp = action_control_id::VARCHAR; - - -- Drop the original UUID column - ALTER TABLE control_administrative - DROP COLUMN action_control_id; - - -- Rename the temporary column to action_control_id - ALTER TABLE control_administrative - RENAME COLUMN action_control_id_temp TO action_control_id; -END $$; - -DO $$ -BEGIN - -- Change the data type of action_control_id from UUID to VARCHAR(36) - - -- First, create a new temporary column with the desired data type - ALTER TABLE control_navigation - ADD COLUMN action_control_id_temp VARCHAR(36); - - -- Update the temporary column with data from the original UUID column - UPDATE control_navigation - SET action_control_id_temp = action_control_id::VARCHAR; - - -- Drop the original UUID column - ALTER TABLE control_navigation - DROP COLUMN action_control_id; - - -- Rename the temporary column to action_control_id - ALTER TABLE control_navigation - RENAME COLUMN action_control_id_temp TO action_control_id; -END $$; - -DO $$ -BEGIN - -- Change the data type of action_control_id from UUID to VARCHAR(36) - - -- First, create a new temporary column with the desired data type - ALTER TABLE control_gens_de_mer - ADD COLUMN action_control_id_temp VARCHAR(36); - - -- Update the temporary column with data from the original UUID column - UPDATE control_gens_de_mer - SET action_control_id_temp = action_control_id::VARCHAR; - - -- Drop the original UUID column - ALTER TABLE control_gens_de_mer - DROP COLUMN action_control_id; - - -- Rename the temporary column to action_control_id - ALTER TABLE control_gens_de_mer - RENAME COLUMN action_control_id_temp TO action_control_id; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.01.18.30__create_infraction_tables.sql b/backend/target/classes/db/migration/V1.2023.11.01.18.30__create_infraction_tables.sql deleted file mode 100644 index fea23243..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.01.18.30__create_infraction_tables.sql +++ /dev/null @@ -1,28 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'infraction') THEN - CREATE TABLE infraction ( - id UUID PRIMARY KEY NOT NULL, - mission_id INT NOT NULL, - control_id UUID NOT NULL, - control_type VARCHAR NOT NULL, - formal_notice BOOLEAN, - observations VARCHAR - ); - END IF; -END $$; - -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'infraction_natinf') THEN - CREATE TABLE infraction_natinf ( - infraction_id UUID NOT NULL, - natinf_code INT NOT NULL, - - PRIMARY KEY (infraction_id, natinf_code), - - -- Define the foreign key constraint for the many-to-one relationship with infraction - CONSTRAINT fk_infractionnatinf_infraction FOREIGN KEY (infraction_id) REFERENCES infraction (id) - ); - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.06.18.30__alter_infraction_add_deletedat.sql b/backend/target/classes/db/migration/V1.2023.11.06.18.30__alter_infraction_add_deletedat.sql deleted file mode 100644 index cdf1450c..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.06.18.30__alter_infraction_add_deletedat.sql +++ /dev/null @@ -1,5 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE infraction - ADD COLUMN deleted_at TIMESTAMP; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.06.20.30__alter_remove_all_deletedat.sql b/backend/target/classes/db/migration/V1.2023.11.06.20.30__alter_remove_all_deletedat.sql deleted file mode 100644 index c65fb958..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.06.20.30__alter_remove_all_deletedat.sql +++ /dev/null @@ -1,20 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE infraction - DROP COLUMN deleted_at; - - ALTER TABLE control_administrative - DROP COLUMN deleted_at; - ALTER TABLE control_security - DROP COLUMN deleted_at; - ALTER TABLE control_navigation - DROP COLUMN deleted_at; - ALTER TABLE control_gens_de_mer - DROP COLUMN deleted_at; - - ALTER TABLE mission_action_control - DROP COLUMN deleted_at; - - ALTER TABLE mission_action_status - DROP COLUMN deleted_at; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.07.19.30__alter_infractions_add_actionid.sql b/backend/target/classes/db/migration/V1.2023.11.07.19.30__alter_infractions_add_actionid.sql deleted file mode 100644 index 856686da..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.07.19.30__alter_infractions_add_actionid.sql +++ /dev/null @@ -1,5 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE infraction - ADD COLUMN action_id VARCHAR(36); -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.07.20.30__create_env_infractions.sql b/backend/target/classes/db/migration/V1.2023.11.07.20.30__create_env_infractions.sql deleted file mode 100644 index 697cf31e..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.07.20.30__create_env_infractions.sql +++ /dev/null @@ -1,19 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.tables - WHERE table_name = 'infraction_env_target' - ) THEN - CREATE TABLE infraction_env_target ( - id UUID PRIMARY KEY, - mission_id INTEGER NOT NULL, - action_id VARCHAR(36) NOT NULL, - infraction_id UUID NOT NULL, - vessel_identifier VARCHAR(64) NOT NULL, - identity_controlled_person VARCHAR(128) NOT NULL, - vessel_type VARCHAR(32) NOT NULL, - vessel_size VARCHAR(32) NOT NULL - ); - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.08.17.30__alter_infraction_field_formalnotice.sql b/backend/target/classes/db/migration/V1.2023.11.08.17.30__alter_infraction_field_formalnotice.sql deleted file mode 100644 index 51cb584b..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.08.17.30__alter_infraction_field_formalnotice.sql +++ /dev/null @@ -1,5 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE infraction DROP COLUMN formal_notice; - ALTER TABLE infraction ADD COLUMN formal_notice varchar(8); -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.08.20.54__create_crew_tables.sql b/backend/target/classes/db/migration/V1.2023.11.08.20.54__create_crew_tables.sql deleted file mode 100644 index 08657871..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.08.20.54__create_crew_tables.sql +++ /dev/null @@ -1,35 +0,0 @@ -CREATE TABLE agent ( - id SERIAL PRIMARY KEY, - first_name VARCHAR(255) NOT NULL, - last_name VARCHAR(255) NOT NULL, - deleted_at TIMESTAMP -); - -CREATE TABLE agent_role ( - id SERIAL PRIMARY KEY, - title VARCHAR(255) NOT NULL -); - - -CREATE TABLE service ( - id SERIAL PRIMARY KEY, - name VARCHAR(255) NOT NULL -); - -CREATE TABLE agent_service ( - agent_id INT, - service_id INT, - FOREIGN KEY (agent_id) REFERENCES agent(id), - FOREIGN KEY (service_id) REFERENCES service(id), - PRIMARY KEY (agent_id, service_id) -); - -CREATE TABLE agent_crew ( - id SERIAL PRIMARY KEY, - agent_id INT, - comment VARCHAR(255) DEFAULT NULL, - agent_role_id INT NOT NULL, - mission_id INT DEFAULT NULL, - FOREIGN KEY (agent_id) REFERENCES agent(id), - FOREIGN KEY (agent_role_id) REFERENCES agent_role(id) -); diff --git a/backend/target/classes/db/migration/V1.2023.11.15.11.09.40__alter_table_service_add_service_linked.sql b/backend/target/classes/db/migration/V1.2023.11.15.11.09.40__alter_table_service_add_service_linked.sql deleted file mode 100644 index e94df47f..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.15.11.09.40__alter_table_service_add_service_linked.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE service -ADD COLUMN service_linked_id INT DEFAULT NULL, -ADD CONSTRAINT fk_service_service_linked -FOREIGN KEY (service_linked_id) REFERENCES service (id) -ON DELETE SET NULL; diff --git a/backend/target/classes/db/migration/V1.2023.11.15.19.30__create_mission_general_info_table.sql b/backend/target/classes/db/migration/V1.2023.11.15.19.30__create_mission_general_info_table.sql deleted file mode 100644 index db1bdec5..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.15.19.30__create_mission_general_info_table.sql +++ /dev/null @@ -1,12 +0,0 @@ -DO $$ -BEGIN - IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'mission_general_info') THEN - CREATE TABLE mission_general_info ( - id INT PRIMARY KEY NOT NULL, - mission_id INT NOT NULL, - distance_in_nautical_miles FLOAT, - consumed_go_in_liters FLOAT, - consumed_fuel_in_liters FLOAT - ); - END IF; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.27__drop_agent_crew_constraint.sql b/backend/target/classes/db/migration/V1.2023.11.27__drop_agent_crew_constraint.sql deleted file mode 100644 index 49051f6e..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.27__drop_agent_crew_constraint.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE agent_crew -DROP CONSTRAINT agent_crew_agent_id_fkey; diff --git a/backend/target/classes/db/migration/V1.2023.11.28.14.30__update_user_link_to_agent.sql b/backend/target/classes/db/migration/V1.2023.11.28.14.30__update_user_link_to_agent.sql deleted file mode 100644 index 57592272..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.28.14.30__update_user_link_to_agent.sql +++ /dev/null @@ -1,11 +0,0 @@ -DO $$ -BEGIN - -- Create a new column with a foreign key constraint allowing NULL - ALTER TABLE "user" - ADD COLUMN agent_id INTEGER REFERENCES "agent"(id); - - -- Add a foreign key constraint explicitly allowing NULL - ALTER TABLE "user" - ADD CONSTRAINT fk_user_agent_id - FOREIGN KEY (agent_id) REFERENCES "agent"(id) ON DELETE SET NULL; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.11.28.20.54__alter_crew_tables.sql b/backend/target/classes/db/migration/V1.2023.11.28.20.54__alter_crew_tables.sql deleted file mode 100644 index e6c53e6e..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.28.20.54__alter_crew_tables.sql +++ /dev/null @@ -1,12 +0,0 @@ - -DROP TABLE agent_crew; - -CREATE TABLE mission_crew ( - id SERIAL PRIMARY KEY, - agent_id INT, - comment VARCHAR(255) DEFAULT NULL, - agent_role_id INT NOT NULL, - mission_id INT DEFAULT NULL, - FOREIGN KEY (agent_id) REFERENCES agent(id), - FOREIGN KEY (agent_role_id) REFERENCES agent_role(id) -); diff --git a/backend/target/classes/db/migration/V1.2023.11.29.10.54__alter_user_tables.sql b/backend/target/classes/db/migration/V1.2023.11.29.10.54__alter_user_tables.sql deleted file mode 100644 index 5a1d7315..00000000 --- a/backend/target/classes/db/migration/V1.2023.11.29.10.54__alter_user_tables.sql +++ /dev/null @@ -1,18 +0,0 @@ -DO $$ -BEGIN - ALTER TABLE "user" - ADD COLUMN first_name VARCHAR(64), - ADD COLUMN last_name VARCHAR(64); - - UPDATE "user" - SET - first_name = name, - last_name = name; - - ALTER TABLE "user" - ALTER COLUMN first_name SET NOT NULL, - ALTER COLUMN last_name SET NOT NULL; - - ALTER TABLE "user" - DROP COLUMN name; -END $$; diff --git a/backend/target/classes/db/migration/V1.2023.12.04.10.54__add_agent_roles.sql b/backend/target/classes/db/migration/V1.2023.12.04.10.54__add_agent_roles.sql deleted file mode 100644 index 828d55fe..00000000 --- a/backend/target/classes/db/migration/V1.2023.12.04.10.54__add_agent_roles.sql +++ /dev/null @@ -1,14 +0,0 @@ -DO $$ -BEGIN - INSERT INTO agent_role (title) VALUES - ('Commandant'), - ('Second capitaine'), - ('Chef mécanicien'), - ('Second mécanicien'), - ('Mécanicien électricien'), - ('Mécanicien'), - ('Chef de quart'), - ('Maître d’équipage'), - ('Agent pont'), - ('Cuisinier'); -END $$; \ No newline at end of file diff --git a/backend/target/classes/db/migration/V1.2023.12.04.11.34__add_services.sql b/backend/target/classes/db/migration/V1.2023.12.04.11.34__add_services.sql deleted file mode 100644 index 2a02f423..00000000 --- a/backend/target/classes/db/migration/V1.2023.12.04.11.34__add_services.sql +++ /dev/null @@ -1,13 +0,0 @@ -DO $$ -BEGIN - INSERT INTO service (id, name, service_linked_id) VALUES - (1, 'pam_jeanne_barret_A', 2), - (2, 'pam_jeanne_barret_B', 1), - (3, 'pam_themis_A', 4), - (4, 'pam_themis_B', 3), - (5, 'pam_iris_A', 6), - (6, 'pam_iris_B', 5), - (7, 'pam_gyptis_A', 8), - (8, 'pam_gyptis_B', 7); - -END $$; \ No newline at end of file diff --git a/backend/target/classes/db/migration/V1.2023.12.04.11.44__add_agents.sql b/backend/target/classes/db/migration/V1.2023.12.04.11.44__add_agents.sql deleted file mode 100644 index 8896e730..00000000 --- a/backend/target/classes/db/migration/V1.2023.12.04.11.44__add_agents.sql +++ /dev/null @@ -1,85 +0,0 @@ -DO $$ -BEGIN - INSERT INTO agent (first_name, last_name) VALUES - -- jeanne barret B: - ('Christian', 'Sauvage'), - ('François', 'Dambron'), - ('Frédéric', 'Grégoire'), - ('Nicolas', 'Delattre'), - ('Jean François', 'Albert'), - ('Guillaume', 'Gatoux'), - ('Arnaud', 'Celton'), - ('Francis', 'Beyaert'), - ('Gaylord', 'Suret'), - ('Thierry', 'Lesaulnier'), - ('Laurent', 'Duval'), - ('Philippe', 'Bon'), - ('Adeline', 'Lagadec'), - ('Pascal', 'Morel'), - ('Yann', 'Mollat'), - -- iris A: - ('Xavier', 'Lacourrege'), - ('Thierry', 'Crochard'), - ('Marc', 'Ottini'), - ('Gilles', 'Menuge'), - ('Jean-David', 'Duhaudt'), - ('Stephane', 'Bistour'), - ('Herve', 'Simon'), - ('Fabien', 'Roman'), - ('Stéphane', 'Lelièvre'), - ('Yves', 'Maniette'), - ('Gaétan', 'Merrien'), - ('Frédéric', 'Beyaert'), - ('Franck', 'Touron'), - ('Frédéric', 'Dechaine'), - ('Francois', 'Le Bon'), - -- themis A: - ('Ariane', 'Regaud'), - ('Philippe', 'Gahinet'), - ('Didier', 'Cozic'), - ('Régis', 'Soubise'), - ('Philippe', 'Davies'), - ('Franck', 'Grouiec'), - ('Stéphane', 'Hellio'), - ('Pascal', 'Rousselet'), - ('Laurent', 'Forgeard'), - ('Oswald', 'Isore'), - ('Yvan', 'Pavie'), - ('Thierry', 'Yhuel'), - ('Stéphane', 'Horel'), - ('Pascal', 'Barinka'), - ('Nicolas', 'Daden'), - ('Cyril', 'Le Scoarnec'), - -- themis B: - ('Frédéric', 'Schneider'), - ('Pascal', 'Isore'), - ('Philippe', 'Fournier'), - ('Régis', 'Tertu'), - ('Raymond', 'Cacitti'), - ('Philippe', 'Darsu'), - ('Michel', 'Marchand'), - ('Cyril', 'Lelandois'), - ('Jean Marc', 'Bourbigot'), - ('David', 'Collomp'), - ('Jérome', 'Fievet'), - ('Brian', 'O’Rorke'), - ('Ludovic', 'Daoulas'), - ('Loup', 'Genty'), - ('JL', 'Chapovaloff'), - -- gyptis A: - ('Ludovic', 'Bouteillon'), - ('Serge', 'Croville'), - ('Sylvain', 'Rebeyrotte'), - ('Thomas', 'Le Gall'), - ('Lilian', 'Roue'), - ('Laurent', 'Paronneau'), - ('Nicolas', 'Peyre'), - ('José', 'Maillot'), - ('Michel', 'Ceres'), - ('David', 'Demilly'), - ('Anne', 'Zamaron'), - ('Cyrille', 'Carval'), - ('Guillaume', 'Mardelle'), - ('Pierre', 'Buriez'); - -END $$; \ No newline at end of file diff --git a/backend/target/classes/db/migration/V1.2023.12.04.11.55__add_agent_service_link.sql b/backend/target/classes/db/migration/V1.2023.12.04.11.55__add_agent_service_link.sql deleted file mode 100644 index de046c95..00000000 --- a/backend/target/classes/db/migration/V1.2023.12.04.11.55__add_agent_service_link.sql +++ /dev/null @@ -1,90 +0,0 @@ -DO $$ -BEGIN - -- Insert into 'agent_service' table -INSERT INTO agent_service (service_id, agent_id) VALUES - -- pam_jeanne_barret_B - (2, 1), -- Christian Sauvage - (2, 2), -- François Dambron - (2, 3), -- Frédéric Grégoire - (2, 4), -- Nicolas Delattre - (2, 5), -- Jean François Albert - (2, 6), -- Guillaume Gatoux - (2, 7), -- Arnaud Celton - (2, 8), -- Francis Beyaert - (2, 9), -- Gaylord Suret - (2, 10), -- Thierry Lesaulnier - (2, 11), -- Laurent Duval - (2, 12), -- Philippe Bon - (2, 13), -- Adeline Lagadec - (2, 14), -- Pascal Morel - (2, 15), -- Yann Mollat - - -- pam_iris_A - (5, 16), -- Xavier Lacourrege - (5, 17), -- Thierry Crochard - (5, 18), -- Marc Ottini - (5, 19), -- Gilles Menuge - (5, 20), -- Jean-David Duhaudt - (5, 21), -- Stephane Bistour - (5, 22), -- Herve Simon - (5, 23), -- Fabien Roman - (5, 24), -- Stéphane Lelièvre - (5, 25), -- Yves Maniette - (5, 26), -- Gaétan Merrien - (5, 27), -- Frédéric Beyaert - (5, 28), -- Franck Touron - (5, 29), -- Frédéric Dechaine - (5, 30), -- Francois Le Bon - - -- pam_themis_A - (3, 31), -- Ariane Regaud - (3, 32), -- Philippe Gahinet - (3, 33), -- Didier Cozic - (3, 34), -- Régis Soubise - (3, 35), -- Philippe Davies - (3, 36), -- Franck Grouiec - (3, 37), -- Stéphane Hellio - (3, 38), -- Pascal Rousselet - (3, 39), -- Laurent Forgeard - (3, 40), -- Oswald Isore - (3, 41), -- Yvan Pavie - (3, 42), -- Thierry Yhuel - (3, 43), -- Stéphane Horel - (3, 44), -- Pascal Barinka - (3, 45), -- Nicolas Daden - (3, 46), -- Cyril Le Scoarnec - - -- pam_themis_B - (4, 47), -- Frédéric Schneider - (4, 48), -- Pascal Isore - (4, 49), -- Philippe Fournier - (4, 50), -- Régis Tertu - (4, 51), -- Raymond Cacitti - (4, 52), -- Philippe Darsu - (4, 53), -- Michel Marchand - (4, 54), -- Cyril Lelandois - (4, 55), -- Jean Marc Bourbigot - (4, 56), -- David Collomp - (4, 57), -- Jérome Fievet - (4, 58), -- Brian O’Rorke - (4, 59), -- Ludovic Daoulas - (4, 60), -- Loup Genty - (4, 61), -- JL Chapovaloff - - -- pam_gyptis_A - (7, 62), -- Ludovic Bouteillon - (7, 63), -- Serge Croville - (7, 64), -- Sylvain Rebeyrotte - (7, 65), -- Thomas Le Gall - (7, 66), -- Lilian Roue - (7, 67), -- Laurent Paronneau - (7, 68), -- Nicolas Peyre - (7, 69), -- José Maillot - (7, 70), -- Michel Ceres - (7, 71), -- David Demilly - (7, 72), -- Anne Zamaron - (7, 73), -- Cyrille Carval - (7, 74), -- Guillaume Mardelle - (7, 75); -- Pierre Buriez - -END $$; \ No newline at end of file diff --git a/backend/target/classes/graphql/action.graphqls b/backend/target/classes/graphql/action.graphqls deleted file mode 100644 index 99ef3c89..00000000 --- a/backend/target/classes/graphql/action.graphqls +++ /dev/null @@ -1,243 +0,0 @@ -extend type Mutation { - status(id: String!): Action - addOrUpdateStatus(statusAction: ActionStatusInput!): NavActionStatus! - deleteStatus(id: String!): Boolean! - addOrUpdateControl(controlAction: ActionControlInput!): NavActionControl! - deleteControl(id: String!): Boolean! -} - -type Action { - id: String - startDateTimeUtc: String! - endDateTimeUtc: String - source: MissionSource! - status: ActionStatusType! - type: ActionType - data: ActionData -} - -input ActionStatusInput { - id: String - missionId: Int! - startDateTimeUtc: String - status: ActionStatusType! - reason: ActionStatusReason - isStart: Boolean! - observations: String -} - -input ActionControlInput { - id: String - missionId: Int! - startDateTimeUtc: String - endDateTimeUtc: String - controlMethod: ControlMethod! - latitude: Float - longitude: Float - vesselType: VesselType! - vesselIdentifier: String - vesselSize: VesselSize - identityControlledPerson: String - observations: String -} - -enum MissionSource { - MONITORENV - MONITORFISH - POSEIDON_CACEM - POSEIDON_CNSP - RAPPORTNAV -} - -union ActionData = - FishActionData - | EnvActionData - | NavActionControl - | NavActionStatus - -type NavActionStatus { - id: String! - startDateTimeUtc: String! - status: ActionStatusType! - reason: ActionStatusReason - isStart: Boolean! - observations: String -} - -enum ActionStatusType { - NAVIGATING - ANCHORED - DOCKED - UNAVAILABLE - UNKNOWN -} -enum ActionStatusReason { - MAINTENANCE - WEATHER - REPRESENTATION - ADMINISTRATION - HARBOUR_CONTROL - OTHER -} - -type NavActionControl { - id: String! - startDateTimeUtc: String! - endDateTimeUtc: String - controlMethod: ControlMethod - latitude: Float - longitude: Float - vesselType: VesselType - vesselIdentifier: String - vesselSize: VesselSize - identityControlledPerson: String - observations: String - controlAdministrative: ControlAdministrative - controlGensDeMer: ControlGensDeMer - controlNavigation: ControlNavigation - controlSecurity: ControlSecurity -} - -enum ControlMethod { - SEA - AIR - LAND -} - -enum VesselType { - FISHING - SAILING - MOTOR - COMMERCIAL - SAILING_LEISURE -} - -enum VesselSize { - LESS_THAN_12m - FROM_12_TO_24m - FROM_24_TO_46m - MORE_THAN_46m -} - -enum ActionType { - CONTROL - SURVEILLANCE - CONTACT - NOTE - STATUS - OTHER -} - -type EnvActionData { - id: String! - actionStartDateTimeUtc: String! - actionEndDateTimeUtc: String! - geom: String - facade: String - department: String - themes: [ThemeEntity] - observations: String - infractions: [InfractionByTarget] - actionNumberOfControls: Int - actionTargetType: ActionTargetTypeEnum - vehicleType: VehicleTypeEnum - availableControlTypes: [ControlType] - controlsToComplete: [ControlType] - controlAdministrative: ControlAdministrative - controlGensDeMer: ControlGensDeMer - controlNavigation: ControlNavigation - controlSecurity: ControlSecurity -} - -type FishActionData { - id: String! - actionDatetimeUtc: String! - vesselId: Int - vesselName: String - latitude: Float - longitude: Float - facade: String - actionType: FishActionType - controlsToComplete: [ControlType] - controlAdministrative: ControlAdministrative - controlGensDeMer: ControlGensDeMer - controlNavigation: ControlNavigation - controlSecurity: ControlSecurity - emitsVms: ControlCheck - emitsAis: ControlCheck - licencesMatchActivity: ControlCheck - logbookMatchesActivity: ControlCheck - licencesAndLogbookObservations: String - gearOnboard: [GearControl] - speciesOnboard: [SpeciesControl] - speciesObservations: String - seizureAndDiversion: Boolean - seizureAndDiversionComments: String - hasSomeGearsSeized: Boolean - hasSomeSpeciesSeized: Boolean - otherComments: String - vesselTargeted: ControlCheck - unitWithoutOmegaGauge: Boolean - controlQualityComments: String - feedbackSheetRequired: Boolean - userTrigram: String - faoAreas: [String] - segments: [FleetSegment] -} - -type FleetSegment { - segment: String - segmentName: String -} - -type GearControl { - comments: String - controlledMesh: Float - declaredMesh: Float - gearCode: String - gearName: String - gearWasControlled: Boolean - hasUncontrolledMesh: Boolean -} - -type SpeciesControl { - speciesCode: String - nbFish: Float - declaredWeight: Float - controlledWeight: Float - underSized: Boolean -} - - -enum ControlCheck { - YES - NO - NOT_APPLICABLE -} - -enum FishActionType { - SEA_CONTROL - LAND_CONTROL - AIR_CONTROL - AIR_SURVEILLANCE - OBSERVATION -} - -type ThemeEntity { - theme: String - subThemes: [String] - protectedSpecies: [String] -} - -enum ActionTargetTypeEnum { - VEHICLE - COMPANY - INDIVIDUAL -} - -enum VehicleTypeEnum { - VESSEL - OTHER_SEA - VEHICLE_LAND - VEHICLE_AIR -} diff --git a/backend/target/classes/graphql/controls.graphqls b/backend/target/classes/graphql/controls.graphqls deleted file mode 100644 index 195f0c04..00000000 --- a/backend/target/classes/graphql/controls.graphqls +++ /dev/null @@ -1,118 +0,0 @@ -extend type Mutation { - addOrUpdateControlNavigation( - control: ControlNavigationInput! - ): ControlNavigation! - addOrUpdateControlSecurity(control: ControlSecurityInput!): ControlSecurity! - addOrUpdateControlAdministrative( - control: ControlAdministrativeInput! - ): ControlAdministrative! - addOrUpdateControlGensDeMer( - control: ControlGensDeMerInput! - ): ControlGensDeMer! - deleteControlAdministrative(actionId: String!): Boolean! - deleteControlSecurity(actionId: String!): Boolean! - deleteControlNavigation(actionId: String!): Boolean! - deleteControlGensDeMer(actionId: String!): Boolean! -} - -enum ControlType { - ADMINISTRATIVE - GENS_DE_MER - NAVIGATION - SECURITY -} - -enum ControlResult { - YES - NO - NOT_CONTROLLED - NOT_CONCERNED -} - -type ControlNavigation { - id: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - observations: String - infractions: [Infraction] -} - -type ControlSecurity { - id: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - observations: String - infractions: [Infraction] -} - -type ControlAdministrative { - id: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - compliantOperatingPermit: ControlResult - upToDateNavigationPermit: ControlResult - compliantSecurityDocuments: ControlResult - observations: String - infractions: [Infraction] -} - -type ControlGensDeMer { - id: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - staffOutnumbered: ControlResult - upToDateMedicalCheck: ControlResult - knowledgeOfFrenchLawAndLanguage: ControlResult - observations: String - infractions: [Infraction] -} - -input ControlNavigationInput { - id: String - missionId: String! - actionControlId: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - observations: String -} - -input ControlSecurityInput { - id: String - missionId: String! - actionControlId: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - observations: String -} - -input ControlAdministrativeInput { - id: String - missionId: String! - actionControlId: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - compliantOperatingPermit: ControlResult - upToDateNavigationPermit: ControlResult - compliantSecurityDocuments: ControlResult - observations: String -} - -input ControlGensDeMerInput { - id: String - missionId: String! - actionControlId: String! - amountOfControls: Int! - unitShouldConfirm: Boolean - unitHasConfirmed: Boolean - staffOutnumbered: ControlResult - upToDateMedicalCheck: ControlResult - knowledgeOfFrenchLawAndLanguage: ControlResult - observations: String -} diff --git a/backend/target/classes/graphql/crew.graphqls b/backend/target/classes/graphql/crew.graphqls deleted file mode 100644 index 0d2135f9..00000000 --- a/backend/target/classes/graphql/crew.graphqls +++ /dev/null @@ -1,55 +0,0 @@ -extend type Query { - agents: [Agent] - agentsByServiceId(serviceId: ID!): [Agent] - agentsByUserService: [Agent] - missionCrewByMissionId(missionId: ID!): [MissionCrew] - agentRoles: [AgentRole] -} - -extend type Mutation { - deleteMissionCrew(id: ID!): Boolean - addOrUpdateMissionCrew(crew: MissionCrewInput!): MissionCrew! -} - -type Agent { - id: ID! - firstName: String! - lastName: String! - services: [Service] -} - -type Service { - id: ID! - name: String! -} - -type AgentRole { - id: ID! - title: String! -} - -type MissionCrew { - id: ID! - agent: Agent - comment: String - role: AgentRole -} - -input MissionCrewInput { - id: ID - agent: AgentInput - missionId: Int! - comment: String - role: AgentRoleInput -} - -input AgentInput { - id: ID - firstName: String! - lastName: String! -} - -input AgentRoleInput { - id: ID - title: String! -} diff --git a/backend/target/classes/graphql/infraction.graphqls b/backend/target/classes/graphql/infraction.graphqls deleted file mode 100644 index 9ba56f12..00000000 --- a/backend/target/classes/graphql/infraction.graphqls +++ /dev/null @@ -1,72 +0,0 @@ -extend type Mutation { - addOrUpdateInfraction(infraction: InfractionInput!): Infraction! - addOrUpdateInfractionForEnvTarget( - infraction: InfractionWithNewTargetInput! - ): Infraction! - deleteInfraction(id: String!): Boolean! -} - -type Infraction { - id: String! - controlType: String - formalNotice: String - natinfs: [Natinf] - observations: String - target: InfractionTarget -} - -type InfractionTarget { - id: String! - vesselIdentifier: String - identityControlledPerson: String - vesselType: VesselType - vesselSize: VesselSize - companyName: String - relevantCourt: String - infractionType: String - formalNotice: String - toProcess: Boolean -} - -# for Env controls, we group by vesselIdentifier -type InfractionByTarget { - vesselIdentifier: String - vesselType: VesselType - infractions: [Infraction] -} - -type Natinf { - infraction: String! - natinfCode: Int! -} - -input InfractionInput { - id: String - missionId: String! - actionId: String! - controlId: String - controlType: String! - formalNotice: String - natinfs: [NatinfInput] - observations: String -} - -input InfractionWithNewTargetInput { - id: String - missionId: String! - actionId: String! - controlId: String - controlType: String! - formalNotice: String - natinfs: [NatinfInput] - observations: String - vesselIdentifier: String! - identityControlledPerson: String! - vesselType: VesselType! - vesselSize: VesselSize! -} - -input NatinfInput { - infraction: String! - natinfCode: Int! -} diff --git a/backend/target/classes/graphql/mission.graphqls b/backend/target/classes/graphql/mission.graphqls deleted file mode 100644 index 700e3c01..00000000 --- a/backend/target/classes/graphql/mission.graphqls +++ /dev/null @@ -1,41 +0,0 @@ -type Query { - missions(userId: ID): [Mission]! - mission(missionId: ID): Mission! - missionGeneralInfo(missionId: ID): MissionGeneralInfo -} - -type Mutation { - updateMission(mission: MissionInput!): Mission! - updateMissionGeneralInfo(info: MissionGeneralInfoInput!): MissionGeneralInfo! -} - -input MissionInput { - id: ID! - startDateTimeUtc: String! - endDateTimeUtc: String! -} - -type Mission { - id: ID! - isClosed: Boolean! - missionSource: String! - startDateTimeUtc: String! - endDateTimeUtc: String - actions: [Action] - generalInfo: MissionGeneralInfo -} - -type MissionGeneralInfo { - id: ID! - distanceInNauticalMiles: Float - consumedGOInLiters: Float - consumedFuelInLiters: Float -} - -input MissionGeneralInfoInput { - id: String - missionId: String! - distanceInNauticalMiles: Float - consumedGOInLiters: Float - consumedFuelInLiters: Float -} diff --git a/backend/target/classes/graphql/user.graphqls b/backend/target/classes/graphql/user.graphqls deleted file mode 100644 index f0606baa..00000000 --- a/backend/target/classes/graphql/user.graphqls +++ /dev/null @@ -1,6 +0,0 @@ -type User { - id: ID - name: String! - email: String! - token: String -} From e7bfc2d0422ec3710354dfa1af4ce0ddab66d760 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 16:11:27 +0100 Subject: [PATCH 12/18] Update env vars and fix feature flags --- .../src/main/resources/application.properties | 16 +- frontend/src/pam/mission/page-header.tsx | 139 +++++++++--------- frontend/src/pam/missions/missions.tsx | 4 - .../backend/application-local.properties | 17 ++- .../backend/application-prod.properties | 12 +- 5 files changed, 103 insertions(+), 85 deletions(-) diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index 42db4a16..b949cbc5 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -7,7 +7,7 @@ spring.web.resources.static-locations=file:${STATIC_FILES_PATH} spring.jpa.hibernate.ddl-auto=validate spring.jpa.show-sql=true #spring.jpa.properties.hibernate.format_sql=true -spring.datasource.url=${spring.datasource.url} +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 @@ -17,7 +17,7 @@ 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} +#spring.devtools.livereload.enabled=${spring.devtools.livereload.enabled} ################ ################ # Server @@ -44,11 +44,11 @@ security.key=somerandomkeywhichislongenoughtoalignwiththejwtspecification ################ ################ # Sentry -sentry.enabled=${sentry.enabled} -sentry.dsn=${sentry.dsn} -sentry.proxy.host=${sentry.proxy.host} -sentry.proxy.port=${sentry.proxy.port} -sentry.traces-sample-rate=${sentry.traces-sample-rate} -sentry.environment=${sentry.environment} +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 diff --git a/frontend/src/pam/mission/page-header.tsx b/frontend/src/pam/mission/page-header.tsx index ad8b5a10..b9760d0d 100644 --- a/frontend/src/pam/mission/page-header.tsx +++ b/frontend/src/pam/mission/page-header.tsx @@ -6,6 +6,7 @@ import Text from '../../ui/text' import { MissionSourceEnum } from "../../types/env-mission-types.ts"; import MissionOpenByTag from "../missions/mission-open-by-tag.tsx"; import GearIcon from '@rsuite/icons/Gear'; +import { useFlag } from "@unleash/proxy-client-react"; const StyledHeader = styled.div` @@ -17,78 +18,82 @@ const StyledHeader = styled.div` ` interface MissionPageHeaderProps { - missionName: string - missionSource?: MissionSourceEnum - onClickClose: () => void - onClickExport: () => void - exportLoading?: boolean + missionName: string + missionSource?: MissionSourceEnum + onClickClose: () => void + onClickExport: () => void + exportLoading?: boolean } const MissionPageHeader: React.FC = ({ - missionName, - missionSource, - onClickClose, - onClickExport, - exportLoading + missionName, + missionSource, + onClickClose, + onClickExport, + exportLoading }) => { - return ( - - - - - - - {missionName} - - - { - !!missionSource && ( - - {/**/} - - {/**/} - - ) - } - - - - - - - - - - - - - - - - - ) + const exportRapportEnabled = useFlag('export_rapport'); + + return ( + + + + + + + {missionName} + + + { + !!missionSource && ( + + {/**/} + + {/**/} + + ) + } + + + + + + + + + + + + + + + + + + + ) } export default MissionPageHeader diff --git a/frontend/src/pam/missions/missions.tsx b/frontend/src/pam/missions/missions.tsx index 44fe4bd5..3393b0a1 100644 --- a/frontend/src/pam/missions/missions.tsx +++ b/frontend/src/pam/missions/missions.tsx @@ -6,15 +6,11 @@ import { Link } from 'react-router-dom' import Text from "../../ui/text.tsx"; import useMissions from "./use-missions.tsx"; import { GET_MISSION_BY_ID } from "../mission/use-mission-by-id.tsx"; -import { useFlag } from "@unleash/proxy-client-react"; const Missions: React.FC = () => { const {loading, data: missions, error, client} = useMissions() - const export_rapport = useFlag('export_rapport'); - console.log('export_rapport enabled: ', export_rapport) - const prefetchMission = async (missionId: string) => { await client.query({ query: GET_MISSION_BY_ID, diff --git a/infra/configurations/backend/application-local.properties b/infra/configurations/backend/application-local.properties index b7e36519..0ce9580a 100644 --- a/infra/configurations/backend/application-local.properties +++ b/infra/configurations/backend/application-local.properties @@ -2,15 +2,24 @@ ################ # Spring spring.datasource.url=jdbc:postgresql://localhost:5432/rapportnavdb?user=postgres&password=postgres +################ +################ +# Logging +logging.level.org.springframework.web=DEBUG +logging.level.org.springframework.security=DEBUG # hot reload: spring.devtools.livereload.enabled=true ################ ################ -# Sentry +# DSI proxy +host.proxy.host= +host.proxy.port= +################ +################ +#Sentry sentry.enabled=false -sentry.dsn= -sentry.proxy.host= -sentry.proxy.port= +sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 sentry.traces-sample-rate=0.0 sentry.environment=local + diff --git a/infra/configurations/backend/application-prod.properties b/infra/configurations/backend/application-prod.properties index 58dc5cd8..b7fa627d 100644 --- a/infra/configurations/backend/application-prod.properties +++ b/infra/configurations/backend/application-prod.properties @@ -6,10 +6,18 @@ spring.datasource.url=jdbc:postgresql://db:5432/rapportnavdb?user=postgres&passw spring.devtools.livereload.enabled=false ################ ################ +# Logging +logging.level.org.springframework.web=DEBUG +logging.level.org.springframework.security=DEBUG +################ +################ +# DSI proxy +host.proxy.host=172.27.229.197 +host.proxy.port=8090 +################ +################ #Sentry sentry.enabled=true sentry.dsn=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 -sentry.proxy.host=172.27.229.197 -sentry.proxy.port=8090 sentry.traces-sample-rate=1.0 sentry.environment=production From f8c9f737669d958975626a4c4b85f18822fd48b1 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 16:11:45 +0100 Subject: [PATCH 13/18] fix sentry env vars --- .../fr/gouv/dgampa/rapportnav/RapportNavApplication.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/RapportNavApplication.kt b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/RapportNavApplication.kt index 315aa61f..90473ebd 100644 --- a/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/RapportNavApplication.kt +++ b/backend/src/main/kotlin/fr/gouv/dgampa/rapportnav/RapportNavApplication.kt @@ -14,15 +14,15 @@ fun main(args: Array) { val ctx = runApplication(*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 } From ffcd9a115fa648d313b51abcec00d4f27ff03618 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 16:12:16 +0100 Subject: [PATCH 14/18] Update hosting docker-compose --- docker-compose.yml.j2 | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml.j2 b/docker-compose.yml.j2 index 2197d0ff..83cb6d10 100644 --- a/docker-compose.yml.j2 +++ b/docker-compose.yml.j2 @@ -44,8 +44,33 @@ services: interval: 1s timeout: 1s retries: 30 -# networks: -# backend_network: + + unleash_proxy: + image: unleashorg/unleash-proxy:v1.1.1 + ports: + - "3000:3000" + environment: + # Proxy clients must use one of these keys to connect to the + # Proxy. To add more keys, separate them with a comma (`key1,key2`). + # UNLEASH_PROXY_CLIENT_KEYS: "randomkey" + UNLEASH_PROXY_SECRETS: "randomkey" + UNLEASH_APP_NAME: "local" + # This points the Proxy to the Unleash server API + UNLEASH_URL: "https://gitlab.com/api/v4/feature_flags/unleash/55951570" + UNLEASH_INSTANCE_ID: "glffct-ceHLxPcFMqyXsyGPXSkx" + # This is the API token that the Proxy uses to communicate with + # the Unleash server. + UNLEASH_API_TOKEN: "glpat-6f7PUWe9PwRoa53LUmsZ" + ENABLE_ALL_ENDPOINT: true + LOG_LEVEL: "debug" + # depends_on: + # - web + healthcheck: + test: wget --no-verbose --tries=1 --spider http://localhost:3000/proxy/health || exit 1 + interval: 1s + timeout: 1m + retries: 5 + volumes: db: name: rapportnavdb From 48cbb05ee9cb837d29a7eeabe893d271137bcc73 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 17:18:38 +0100 Subject: [PATCH 15/18] fix frontend test + update frontend mode for Trivy Dockerfile --- frontend/.env.ci.defaults | 4 + .../src/pam/mission/mission-page.test.tsx | 9 ++ frontend/src/pam/mission/page-header.tsx | 135 +++++++++--------- frontend/src/pam/missions/missions.test.tsx | 71 +++++---- infra/docker/app/DockerfileCI | 2 +- 5 files changed, 116 insertions(+), 105 deletions(-) create mode 100644 frontend/.env.ci.defaults diff --git a/frontend/.env.ci.defaults b/frontend/.env.ci.defaults new file mode 100644 index 00000000..3a7d63ab --- /dev/null +++ b/frontend/.env.ci.defaults @@ -0,0 +1,4 @@ +################################################################################ +# Sentry + +FRONTEND_SENTRY_DSN=https://loremipsum.com diff --git a/frontend/src/pam/mission/mission-page.test.tsx b/frontend/src/pam/mission/mission-page.test.tsx index a96162ed..6efd4b03 100644 --- a/frontend/src/pam/mission/mission-page.test.tsx +++ b/frontend/src/pam/mission/mission-page.test.tsx @@ -6,6 +6,15 @@ import useMissionExcerpt from "./general-info/use-mission-excerpt"; import { GraphQLError } from "graphql/error"; import { useNavigate } from "react-router-dom"; +vi.mock("@unleash/proxy-client-react", async (importOriginal) => { + const actual = await importOriginal() + return { + ...actual, + useFlag: vi.fn(), + default: vi.fn() + } +}) + // Mock the useApolloClient hook const mockApolloClient = { resetStore: vi.fn(), diff --git a/frontend/src/pam/mission/page-header.tsx b/frontend/src/pam/mission/page-header.tsx index b9760d0d..a507622e 100644 --- a/frontend/src/pam/mission/page-header.tsx +++ b/frontend/src/pam/mission/page-header.tsx @@ -18,82 +18,81 @@ const StyledHeader = styled.div` ` interface MissionPageHeaderProps { - missionName: string - missionSource?: MissionSourceEnum - onClickClose: () => void - onClickExport: () => void - exportLoading?: boolean + missionName: string + missionSource?: MissionSourceEnum + onClickClose: () => void + onClickExport: () => void + exportLoading?: boolean } const MissionPageHeader: React.FC = ({ - missionName, - missionSource, - onClickClose, - onClickExport, - exportLoading + missionName, + missionSource, + onClickClose, + onClickExport, + exportLoading }) => { - const exportRapportEnabled = useFlag('export_rapport'); + const exportRapportEnabled = useFlag('export_rapport'); - return ( - - - - - - - {missionName} - - - { - !!missionSource && ( - - {/**/} - - {/**/} - - ) - } - - - - - - - - + return ( + + + + + + + {missionName} + + + { + !!missionSource && ( + + {/**/} + + {/**/} + + ) + } + + + + + + + + - - - - + + + + - - - - - ) + + + + + ) } export default MissionPageHeader diff --git a/frontend/src/pam/missions/missions.test.tsx b/frontend/src/pam/missions/missions.test.tsx index d5503b39..43b42101 100644 --- a/frontend/src/pam/missions/missions.test.tsx +++ b/frontend/src/pam/missions/missions.test.tsx @@ -5,53 +5,52 @@ import { Mission } from "../../types/mission-types.ts"; import Missions from "./missions.tsx"; import { GraphQLError } from "graphql/error"; - vi.mock("./use-missions.tsx", async (importOriginal) => { - const actual = await importOriginal() - return { - ...actual, - default: vi.fn() - } + const actual = await importOriginal() + return { + ...actual, + default: vi.fn() + } }) const mission = { - id: '123', - agent: { - id: 'abc', - firstName: 'firstName', - lastName: 'lastName', - services: [] - }, - comment: undefined, - role: undefined + id: '123', + agent: { + id: 'abc', + firstName: 'firstName', + lastName: 'lastName', + services: [] + }, + comment: undefined, + role: undefined } const mockedQueryResult = (crew?: Mission[], loading: boolean = false, error: any = undefined) => ({ - data: crew, - loading, - error, + data: crew, + loading, + error, }) describe('Missions', () => { - describe('Testing rendering', () => { - test('should render loading', () => { - ;(useMissions as any).mockReturnValue(mockedQueryResult(undefined, true)) - render(); - expect(screen.getByText('Missions en cours de chargement')).toBeInTheDocument(); - }); - - test('should render error', () => { - ;(useMissions as any).mockReturnValue(mockedQueryResult(undefined, false, new GraphQLError("Error!"))) - render(); - expect(screen.getByText('Erreur: Error!')).toBeInTheDocument(); - }); - - test('should render content', () => { - ;(useMissions as any).mockReturnValue(mockedQueryResult([mission])) - render(); - expect(screen.getByText('Mes rapports de mission')).toBeInTheDocument(); - }); + describe('Testing rendering', () => { + test('should render loading', () => { + ;(useMissions as any).mockReturnValue(mockedQueryResult(undefined, true)) + render(); + expect(screen.getByText('Missions en cours de chargement')).toBeInTheDocument(); + }); + + test('should render error', () => { + ;(useMissions as any).mockReturnValue(mockedQueryResult(undefined, false, new GraphQLError("Error!"))) + render(); + expect(screen.getByText('Erreur: Error!')).toBeInTheDocument(); + }); + + test('should render content', () => { + ;(useMissions as any).mockReturnValue(mockedQueryResult([mission])) + render(); + expect(screen.getByText('Mes rapports de mission')).toBeInTheDocument(); }); + }); }); diff --git a/infra/docker/app/DockerfileCI b/infra/docker/app/DockerfileCI index 19493fcb..1412adb6 100644 --- a/infra/docker/app/DockerfileCI +++ b/infra/docker/app/DockerfileCI @@ -40,7 +40,7 @@ FROM node:18 AS build-frontend WORKDIR /tmp/frontend COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules COPY frontend . -RUN npm run build --verbose +RUN npm run build --verbose --mode ci From e887ece48a880c7335149efe0319a52f597a99ab Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 17:30:40 +0100 Subject: [PATCH 16/18] update frontend mode for Trivy Dockerfile --- frontend/{.env.ci.defaults => .env.production.defaults} | 2 +- infra/docker/app/DockerfileCI | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename frontend/{.env.ci.defaults => .env.production.defaults} (51%) diff --git a/frontend/.env.ci.defaults b/frontend/.env.production.defaults similarity index 51% rename from frontend/.env.ci.defaults rename to frontend/.env.production.defaults index 3a7d63ab..4e2331c9 100644 --- a/frontend/.env.ci.defaults +++ b/frontend/.env.production.defaults @@ -1,4 +1,4 @@ ################################################################################ # Sentry -FRONTEND_SENTRY_DSN=https://loremipsum.com +FRONTEND_SENTRY_DSN=https://8857258f9f1549968b13e15759bdf2bc@sentry.incubateur.net/121 diff --git a/infra/docker/app/DockerfileCI b/infra/docker/app/DockerfileCI index 1412adb6..602535d9 100644 --- a/infra/docker/app/DockerfileCI +++ b/infra/docker/app/DockerfileCI @@ -40,7 +40,7 @@ FROM node:18 AS build-frontend WORKDIR /tmp/frontend COPY --from=npm-dependencies /tmp/frontend/node_modules ./node_modules COPY frontend . -RUN npm run build --verbose --mode ci +RUN npm run build --verbose --mode production From 6510fbfde849ad5f6760c74b4049724dc35d2628 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 17:34:31 +0100 Subject: [PATCH 17/18] update frontend build command --- frontend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/package.json b/frontend/package.json index e34356e7..fa20d36b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,7 @@ }, "scripts": { "dev": "import-meta-env-prepare -x ./.env.local.defaults && vite", - "build": "vite build && import-meta-env -x .env.example -p dist/index.html", + "build": "import-meta-env-prepare -x ./.env.local.defaults && vite build && import-meta-env -x .env.example -p dist/index.html", "build:with-sourcemaps": "vite build --sourcemap", "tsc": "tsc", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10000", From de31914c6bb540c6f2ce9672d8b89d9738b42517 Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 19 Mar 2024 17:43:46 +0100 Subject: [PATCH 18/18] Sentry fixes and cleanup frontend commands --- frontend/package.json | 5 +++-- frontend/src/sentry.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index fa20d36b..799bad55 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -7,8 +7,9 @@ "node": ">=20.0.0" }, "scripts": { - "dev": "import-meta-env-prepare -x ./.env.local.defaults && vite", - "build": "import-meta-env-prepare -x ./.env.local.defaults && vite build && import-meta-env -x .env.example -p dist/index.html", + "env-prepare": "import-meta-env-prepare -x ./.env.local.defaults", + "dev": "npm run env-prepare && vite", + "build": "npm run env-prepare && vite build && import-meta-env -x .env.example -p dist/index.html", "build:with-sourcemaps": "vite build --sourcemap", "tsc": "tsc", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 10000", diff --git a/frontend/src/sentry.ts b/frontend/src/sentry.ts index 9b592850..e9cbcd72 100644 --- a/frontend/src/sentry.ts +++ b/frontend/src/sentry.ts @@ -2,13 +2,15 @@ import { useEffect } from "react"; import { init, reactRouterV6BrowserTracingIntegration, replayIntegration } from "@sentry/react"; import { createRoutesFromChildren, matchRoutes, useLocation, useNavigationType } from "react-router-dom"; import { captureConsoleIntegration, debugIntegration, httpClientIntegration } from "@sentry/integrations"; +import packageJson from '../package.json'; + +const version = packageJson.version; const initSentry = () => { const FRONTEND_SENTRY_DSN = import.meta.env.FRONTEND_SENTRY_DSN const viteMode = import.meta.env.MODE const isDev = import.meta.env.DEV - // const release = "rapportnav2@" + process.env.npm_package_version - const release = "rapportnav2@" + "1" + const release = version init({ dsn: FRONTEND_SENTRY_DSN,