Skip to content

Commit

Permalink
feat: typescript et précalcule des isochrones (#4)
Browse files Browse the repository at this point in the history
chore: typescript
feat: precalcule des isochrones
  • Loading branch information
K4ST0R authored Sep 9, 2024
1 parent 96b53f3 commit f4fda5d
Show file tree
Hide file tree
Showing 165 changed files with 132,693 additions and 137,685 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,8 @@ dist
trajectoires-pro.Rproj
.Rhistory
.Rdata

server/data/isochrones/
server/data/isochrones_output/

tmp/
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -eu
function validate_commit() {
cd .
local sensible_files_pattern="\.(csv|xls|xls(x?)|json|env)$"
local exception="package.json$|tsconfig.json$|server/data/depp(.*).csv$|bcn/n_mef.csv$|server/jsconfig.json$|acce_etablissements.csv$|server/tests/fixtures/files/*.json$|server/data/educationGouv/(.*).csv$|server/data/orion/(.*).csv$|server/public/remixicon/remixicon.*.json$"
local exception="package.json$|tsconfig.json$|server/data/depp(.*).csv$|bcn/n_mef.csv$|server/jsconfig.json$|server/.mocharc.json$|acce_etablissements.csv$|server/tests/fixtures/files/*.json$|server/data/educationGouv/(.*).csv$|server/data/orion/(.*).csv$|server/public/remixicon/remixicon.*.json$"
local files
files=$(git diff --cached --name-only | grep -v -E "$exception" | grep -E "$sensible_files_pattern") || true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ services:
- ACCOMPAGNATEUR_SLACK_WEBHOOK_URL={{ vault.ACCOMPAGNATEUR_SLACK_WEBHOOK_URL }}
- CATALOGUE_APPRENTISSAGE_USERNAME={{ vault.CATALOGUE_APPRENTISSAGE_USERNAME }}
- CATALOGUE_APPRENTISSAGE_PASSWORD={{ vault.CATALOGUE_APPRENTISSAGE_PASSWORD }}
- ACCOMPAGNATEUR_POSTGRES_URI={{ vault.ACCOMPAGNATEUR_POSTGRES_URI }}
- ACCOMPAGNATEUR_POSTGRES_CA={{ vault.ACCOMPAGNATEUR_POSTGRES_CA }}
- DATABASE_URL={{ vault.ACCOMPAGNATEUR_POSTGRES_URI }}

metabase:
mem_limit: 4g
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ services:
- ACCOMPAGNATEUR_MONGODB_URI=mongodb://accompagnateur:{{ vault.ACCOMPAGNATEUR_MONGODB_USER_PASSWORD }}@mongodb:27017/accompagnateur?authSource=admin&retryWrites=true&w=majority
- CATALOGUE_APPRENTISSAGE_USERNAME={{ vault.CATALOGUE_APPRENTISSAGE_USERNAME }}
- CATALOGUE_APPRENTISSAGE_PASSWORD={{ vault.CATALOGUE_APPRENTISSAGE_PASSWORD }}

- ACCOMPAGNATEUR_POSTGRES_URI={{ vault.ACCOMPAGNATEUR_RECETTE_POSTGRES_URI }}
- ACCOMPAGNATEUR_POSTGRES_CA={{ vault.ACCOMPAGNATEUR_RECETTE_POSTGRES_CA }}
- DATABASE_URL={{ vault.ACCOMPAGNATEUR_RECETTE_POSTGRES_URI }}

metabase:
environment:
- MB_SITE_URL=https://{{ dns_name }}/metabase
2 changes: 1 addition & 1 deletion .infra/ansible/roles/setup/files/app/monitor-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function reload_containers() {

function verify_app() {
if wget --timeout 15 -O - -q -t 4 ${URL} |
jq --exit-status '.healthcheck.mongodb == true' >/dev/null; then
jq --exit-status '.healthcheck.sql == true' >/dev/null; then
true
else
false
Expand Down
235 changes: 161 additions & 74 deletions .infra/ansible/roles/setup/vars/main/vault.yml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"bracketSpacing": true,
"trailingComma": "es5",
"arrowParens": "always"
}
27 changes: 25 additions & 2 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ services:

ui:
build:
dockerfile: ./Dockerfile.dev
dockerfile: ./ui/Dockerfile.dev
mem_limit: 1g
stdin_open: true
volumes:
- accompagnateur_ui_data:/data:z
- /app/node_modules
- ./ui:/app:z
server:
command: ["yarn", "debug"]
command: ["yarn", "dev"]
ports:
- "127.0.0.1:9229:9229" # Allows remote debugging
volumes:
Expand All @@ -32,6 +32,26 @@ services:
volumes:
- accompagnateur_mongodb_data:/data:z

postgres:
image: postgis/postgis:16-3.4
command:
- "postgres"
- "-c"
- "shared_buffers=512MB"
- "-c"
- "work_mem=32MB"
shm_size: 1g
container_name: accompagnateur_postgres
restart: unless-stopped
networks:
- accompagnateur_network
environment:
- POSTGRES_PASSWORD=password
ports:
- "5432:5432"
volumes:
- accompagnateur_postgres_data:/var/lib/postgresql/data:z

metabase:
volumes:
- accompagnateur_metabase_data:/data:z
Expand All @@ -43,6 +63,9 @@ volumes:
accompagnateur_mongodb_data:
driver: local
name: accompagnateur_mongodb_data
accompagnateur_postgres_data:
driver: local
name: accompagnateur_postgres_data
accompagnateur_nginx_data:
driver: local
name: accompagnateur_nginx_data
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ services:
image: accompagnateur_ui
container_name: accompagnateur_ui
build:
context: ui
context: ./
dockerfile: ./ui/Dockerfile
mem_limit: 1g
restart: unless-stopped
networks:
Expand All @@ -44,16 +45,17 @@ services:
image: accompagnateur_server
container_name: accompagnateur_server
build:
context: server
context: ./
dockerfile: ./server/Dockerfile
mem_limit: 1g
restart: unless-stopped
networks:
- accompagnateur_network
depends_on:
- mongodb
environment:
- ACCOMPAGNATEUR_MONGODB_URI=mongodb://mongodb:27017/accompagnateur?retryWrites=true&w=majority
- ACCOMPAGNATEUR_LOG_DESTINATIONS=stdout,mongodb
- ACCOMPAGNATEUR_LOG_DESTINATIONS=stdout,sql
- ACCOMPAGNATEUR_SQL_LOG_LEVEL=error

mongodb:
image: mongo:5.0.6-focal
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"description": "[InserJeunes] Accompagnateur",
"repository": "https://github.com/mission-apprentissage/c-est-qui-le-pro.git",
"private": true,
"workspaces": [
"server",
"ui"
],
"author": "InserJeunes",
"license": "MIT",
"scripts": {
Expand All @@ -18,6 +22,7 @@
"@semantic-release/exec": "6.0.3",
"@semantic-release/git": "10.0.1",
"husky": "^8.0.3",
"prettier": "2.6.2",
"semantic-release": "19.0.2",
"semantic-release-slack-bot": "3.5.2"
},
Expand All @@ -27,4 +32,4 @@
"trailingComma": "es5"
},
"packageManager": "[email protected]"
}
}
9 changes: 9 additions & 0 deletions server/.config/kysely.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig, getKnexTimestampPrefix } from "kysely-ctl";
import { kdb } from "#src/common/db/db.ts";

export default defineConfig({
kysely: kdb,
migrations: {
getMigrationPrefix: getKnexTimestampPrefix,
},
});
11 changes: 11 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ACCOMPAGNATEUR_LOG_LEVEL: info
ACCOMPAGNATEUR_LOG_DESTINATIONS: stdout,sql
CATALOGUE_APPRENTISSAGE_USERNAME: "tmp"
CATALOGUE_APPRENTISSAGE_PASSWORD: "tmp"
ACCOMPAGNATEUR_ENV: dev
EXPOSITION_API_USERNAME: "tmp"
EXPOSITION_API_PASSWORD: "tmp"
ACCOMPAGNATEUR_POSTGRES_URI: "tmp"
DATABASE_URL: "tmp"
ACCOMPAGNATEUR_POSTGRES_CA: ""
ACCOMPAGNATEUR_SQL_LOG_LEVEL: error
13 changes: 11 additions & 2 deletions server/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
"node-option": [
"import=tsx",
"enable-source-maps"
],
"extension": [
"ts"
],
"timeout": 5000,
"exit": true,
"recursive": true,
"require": "tests/utils/mochaGlobalFixtures.js",
"require": [
"tests/utils/mochaGlobalFixtures.js"
],
"reporter": "tests/utils/mochaReporter.cjs"
}
}
15 changes: 8 additions & 7 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
FROM node:18-alpine

#Install and cache node_modules
COPY package.json yarn.lock /tmp/
RUN cd /tmp && \
yarn install --frozen-lockfile && \
mkdir -p /app && \
mv /tmp/node_modules /app/
WORKDIR /base
COPY package.json .
COPY yarn.lock .
COPY server/package.json server/
RUN yarn install --frozen-lockfile

COPY ./ /app
WORKDIR /app
COPY ./server server
RUN yarn workspace server build

WORKDIR /base/server
VOLUME /data
EXPOSE 5000
CMD ["yarn", "start"]
Loading

0 comments on commit f4fda5d

Please sign in to comment.