Skip to content

Commit

Permalink
Merge pull request #1702 from Inist-CNRS/lodex-node-14
Browse files Browse the repository at this point in the history
Update node from 12 to 14
  • Loading branch information
touv authored Sep 26, 2023
2 parents ba3fe64 + f985bee commit 7d67176
Show file tree
Hide file tree
Showing 19 changed files with 1,353 additions and 664 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine AS build
FROM node:14-alpine AS build
RUN apk add --no-cache make gcc g++ python3 bash git openssh jq
WORKDIR /app
COPY ./package.json /app
Expand All @@ -18,7 +18,7 @@ RUN mkdir /app/upload && \
npm prune --production && \
npm run clean

FROM node:12-alpine AS release
FROM node:14-alpine AS release
RUN apk add --no-cache su-exec redis
COPY --from=build /app /app

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine
FROM node:14-alpine

WORKDIR /app
COPY ./package.json /app
Expand Down
42 changes: 21 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,76 +35,76 @@ endif
install-npm-dependencies:
echo "Installing Node dependencies"
ifeq "$(CI)" "true"
docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm ci
docker compose -f docker-compose.dev.yml run --no-deps --rm node npm ci
else
docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm install
docker compose -f docker-compose.dev.yml run --no-deps --rm node npm install
endif

install: copy-conf install-npm-dependencies ## Install npm dependencies for the node, admin, and frontend apps

## Production =================================================================

run: ## Run the project in production mode
docker-compose up --force-recreate
docker compose up --force-recreate
start: run ## Start the project (alias of make run)

## Development =================================================================

run-dev: ## Run the project in dev mode
docker-compose -f docker-compose.dev.yml up --force-recreate
NODE_ENV=development docker compose -f docker-compose.dev.yml up --force-recreate
start-dev: run-dev ## Start the project (alias of make run-dev)

build-app:
docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm run build
docker compose -f docker-compose.dev.yml run --no-deps --rm node npm run build

build: ## Build the docker image localy
docker build -t inistcnrs/lodex:14.0.8-alpha --build-arg http_proxy --build-arg https_proxy .
publish: build ## publish version to docker hub
docker push inistcnrs/lodex:14.0.8-alpha

analyze-code: ## Generate statistics about the bundle. Usage: make analyze-code.
docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm run analyze
docker compose -f docker-compose.dev.yml run --no-deps --rm node npm run analyze

npm: ## allow to run dockerized npm command eg make npm 'install koa --save'
docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm $(COMMAND_ARGS)
docker compose -f docker-compose.dev.yml run --no-deps --rm node npm $(COMMAND_ARGS)

## Tests =======================================================================

test-api-e2e: ## Run the API E2E tests
NODE_ENV=test \
EZMASTER_PUBLIC_URL="http://localhost:3010" \
docker-compose -f docker-compose.dev.yml run --rm -p "3010:3010" node \
docker compose -f docker-compose.dev.yml run --rm -p "3010:3010" node \
npm run test:api:e2e

test-api-e2e-watch: ## Run the API E2E tests in watch mode
NODE_ENV=test \
EZMASTER_PUBLIC_URL="http://localhost:3010" \
docker-compose -f docker-compose.dev.yml run --rm -p "3010:3010" node \
docker compose -f docker-compose.dev.yml run --rm -p "3010:3010" node \
npm run test:api:e2e:watch

test-unit: ## Run the unit tests, usage : JEST_OPTIONS=myfile.to.test.spec.js make test-unit
## You can use other Jest options (https://jestjs.io/fr/docs/cli)
NODE_ENV=test docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm run test:unit -- $(JEST_OPTIONS)
NODE_ENV=test docker compose -f docker-compose.dev.yml run --no-deps --rm node npm run test:unit -- $(JEST_OPTIONS)

test-unit-watch: ## Run the unit tests, usage : JEST_OPTIONS=myfile.to.test.spec.js make test-unit-watch
## You can use other Jest options (https://jestjs.io/fr/docs/cli)
NODE_ENV=test docker-compose -f docker-compose.dev.yml run --no-deps --rm node npm run test:unit:watch -- $(JEST_OPTIONS)
NODE_ENV=test docker compose -f docker-compose.dev.yml run --no-deps --rm node npm run test:unit:watch -- $(JEST_OPTIONS)

test-e2e-start-dockers:
ifeq "$(CI)" "true"
docker-compose -f docker-compose.spec.yml up -d --build
docker compose -f docker-compose.spec.yml up -d --build
else
docker-compose -f docker-compose.spec.yml up --build
docker compose -f docker-compose.spec.yml up --build
endif

test-e2e-logs:
docker-compose -f docker-compose.spec.yml logs
docker compose -f docker-compose.spec.yml logs

test-e2e-logs-watch:
docker-compose -f docker-compose.spec.yml logs -f
docker compose -f docker-compose.spec.yml logs -f

test-e2e-stop-dockers:
docker-compose -f docker-compose.spec.yml down
docker compose -f docker-compose.spec.yml down

test-e2e-open-cypress:
NODE_ENV=e2e npx cypress open
Expand All @@ -128,16 +128,16 @@ test: ## Run all tests
## Data ========================================================================

mongo: ## Start the mongo database
docker-compose up -d mongo
docker compose up -d mongo

mongo-shell: ## Start the mongo shell
docker-compose exec mongo mongo lodex
docker compose exec mongo mongo lodex

mongo-shell-test: ## Start the mongo shell for the test database
docker-compose exec mongo mongo lodex_test
docker compose exec mongo mongo lodex_test

clear-database: ## Clear the whole database
docker-compose exec mongo mongo lodex --eval " \
docker compose exec mongo mongo lodex --eval " \
db.publishedDataset.remove({}); \
db.publishedCharacteristic.remove({}); \
db.field.remove({}); \
Expand All @@ -147,7 +147,7 @@ clear-database: ## Clear the whole database
db.enrichment.remove({}); \
"
clear-publication: ## Clear the published data, keep uploaded dataset and model
docker-compose exec mongo mongo lodex --eval " \
docker compose exec mongo mongo lodex --eval " \
db.publishedDataset.remove({}); \
db.publishedCharacteristic.remove({}); \
db.publishedFacet.remove({}); \
Expand Down
19 changes: 9 additions & 10 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
node:
image: node:12
image: node:14
volumes:
- .:/app
working_dir: /app
Expand All @@ -27,40 +27,39 @@ services:
- redis
- workers
ports:
- 3000:3000
- 9229:9229 # Enable Nodemon inspect to attach to Docker Node
- "3000:3000"
- "9229:9229" # Enable Nodemon inspect to attach to Docker Node
command: npm run development:api

dev-server: ## Enable hot-reload in development
image: node:12
image: node:14
volumes:
- .:/app
working_dir: /app
user: '${UID}:${GID}'
environment:
NODE_ENV: development
ports:
- 8080:8080
- "8080:8080"
command: npm run development:app

mongo:
image: mongo:4.4.4-bionic
ports:
- 27017:27017
- "27017:27017"

redis:
image: redis:6
ports:
- 6379:6379
- "6379:6379"

workers:
image: node:12
image: node:14
volumes:
- .:/app
working_dir: /app
user: '${UID}:${GID}'
environment:
NODE_ENV: development
DEBUG: ${DEBUG}
NODE_ENV: ${NODE_ENV}
NODE_OPTIONS: ${NODE_OPTIONS}
Expand All @@ -75,7 +74,7 @@ services:
EZS_NSHARDS: '31'
EZS_CACHE: 'false'
ports:
- 31976:31976
- "31976:31976"
command: npm run production:workers
links:
- mongo
Expand Down
15 changes: 7 additions & 8 deletions docker-compose.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,39 @@ services:
- redis
- workers
ports:
- 3000:3000
- "3000:3000"
volumes:
- ./cypress/mocks/external:/app/external

istex-api:
image: node:12
image: node:14
volumes:
- .:/app
working_dir: /app
user: '${UID}:${GID}'
environment:
NODE_ENV: 'test'
ports:
- 3011:3011
- "3011:3011"
command: node --require @babel/register ./cypress/mocks/istexApi.js

mongo:
image: mongo:4.4.4-bionic
ports:
- 27017:27017
- "27017:27017"

redis:
image: redis:6
ports:
- 6379:6379
- "6379:6379"

workers:
image: node:12
image: node:14
volumes:
- .:/app
working_dir: /app
user: '${UID}:${GID}'
environment:
NODE_ENV: development
DEBUG: ${DEBUG}
NODE_ENV: ${NODE_ENV}
NODE_OPTIONS: ${NODE_OPTIONS}
Expand All @@ -71,7 +70,7 @@ services:
EZS_NSHARDS: '31'
EZS_CACHE: 'false'
ports:
- 31976:31976
- "31976:31976"
command: npm run production:workers
links:
- mongo
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ services:
links:
- mongo
ports:
- 3000:3000
- "3000:3000"
mongo:
image: mongo:4.4.4-bionic
ports:
- 27017:27017
- "27017:27017"
2 changes: 1 addition & 1 deletion jest-mongodb-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
dbName: 'jest',
},
binary: {
version: '4.0.3',
version: '4.4.4',
skipMD5: true,
},
autoStart: false,
Expand Down
Loading

0 comments on commit 7d67176

Please sign in to comment.