mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-13 17:56:20 +00:00
refactor: app deployment
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
integration:backend:
|
||||
image: registry.gitlab.com/openstapps/projectmanagement/builder:v18
|
||||
stage: test
|
||||
dependencies:
|
||||
- build
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
WAIT_FOR_SERVICES_TIMEOUT: 1
|
||||
services:
|
||||
- docker:dind
|
||||
- name: registry.gitlab.com/openstapps/database:latest
|
||||
alias: elasticsearch
|
||||
script:
|
||||
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
||||
- pnpm install --offline
|
||||
- pnpm --filter=@openstapps/backend --filter=@openstapps/api-cli install --prefer-offline
|
||||
- pnpm test:integration
|
||||
tags:
|
||||
- secrecy
|
||||
- performance
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
- backend/backend/coverage/integration-report-junit.xml
|
||||
reports:
|
||||
junit:
|
||||
- backend/backend/coverage/integration-report-junit.xml
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
FROM registry.gitlab.com/openstapps/projectmanagement/node:v18
|
||||
|
||||
USER root
|
||||
RUN apk add --update python3 py3-pip make g++ gcompat
|
||||
|
||||
USER node
|
||||
ADD --chown=node:node . /app
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /app
|
||||
|
||||
COPY --chown=node:node --from=pruned pruned .
|
||||
|
||||
EXPOSE 3000
|
||||
ENTRYPOINT ["node", "app.js"]
|
||||
|
||||
22
backend/backend/integration-test.sh
Executable file
22
backend/backend/integration-test.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
ES_HOST="elasticsearch"
|
||||
BACKEND_HOST="localhost"
|
||||
if [ -z $GITLAB_CI ]; then
|
||||
ES_HOST=localhost
|
||||
fi
|
||||
|
||||
( STAPPS_LOG_LEVEL=31 STAPPS_EXIT_LEVEL=8 NODE_CONFIG_ENV=elasticsearch NODE_ENV=integration-test ALLOW_NO_TRANSPORT=true ES_ADDR=http://$ES_HOST:9200 node app.js ) & backend_pid=$!
|
||||
( openstapps-api e2e http://$BACKEND_HOST:3000 --reportPath coverage/integration-report-junit.xml --waiton tcp:$BACKEND_HOST:3000 --samples node_modules/@openstapps/core/test/resources/indexable ) & api_cli_pid=$!
|
||||
|
||||
## Check output codes
|
||||
# api-cli output defines passing the test
|
||||
# backend should not exit early
|
||||
|
||||
wait $api_cli_pid
|
||||
api_cli_exit=$?
|
||||
wait $backend_pid
|
||||
backend_exit=$?
|
||||
|
||||
if [ "$api_cli_exit" -eq "0" ]; then
|
||||
echo "FINISHED";
|
||||
exit;
|
||||
fi
|
||||
@@ -1,7 +1,9 @@
|
||||
version: '3'
|
||||
services:
|
||||
backend:
|
||||
build: .
|
||||
build:
|
||||
dockerfile: ./Dockerfile
|
||||
context: ../../.deploy/backend
|
||||
ports:
|
||||
- '3000:3000'
|
||||
environment:
|
||||
@@ -11,6 +13,7 @@ services:
|
||||
NODE_ENV: 'integration-test'
|
||||
ALLOW_NO_TRANSPORT: 'true'
|
||||
ES_ADDR: 'http://elasticsearch:9200'
|
||||
command: wait-for http://elasticsearch:9200 -t 120 -- node app.js
|
||||
|
||||
elasticsearch:
|
||||
build: ../database
|
||||
@@ -18,7 +21,9 @@ services:
|
||||
- '9200:9200'
|
||||
|
||||
api-cli:
|
||||
build: ../../packages/api-cli
|
||||
build:
|
||||
dockerfile: ../../packages/api-cli/Dockerfile
|
||||
context: ../../.deploy/api-cli
|
||||
environment:
|
||||
STAPPS_LOG_LEVEL: '31'
|
||||
STAPPS_EXIT_LEVEL: '8'
|
||||
|
||||
@@ -21,21 +21,22 @@
|
||||
"app.js",
|
||||
"lib",
|
||||
"config",
|
||||
"Dockerfile",
|
||||
"README.md",
|
||||
"ROUTES.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup-node",
|
||||
"deploy": "pnpm --prod --filter=@openstapps/backend deploy ../../.deploy/backend",
|
||||
"dev": "tsup --watch --onSuccess \"pnpm run start\"",
|
||||
"format": "prettier . -c --ignore-path ../../.gitignore",
|
||||
"format:fix": "prettier --write . --ignore-path ../../.gitignore",
|
||||
"lint": "tsc --noEmit && eslint --ext .ts src/",
|
||||
"lint:fix": "eslint --fix --ext .ts src/",
|
||||
"prune:integration": "pnpm --filter=backend --prod deploy pruned && pnpm --filter=api-cli --prod deploy ../../packages/api-cli/pruned",
|
||||
"start": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
|
||||
"start:debug": "cross-env STAPPS_LOG_LEVEL=31 NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true node app.js",
|
||||
"test": "pnpm run test:unit",
|
||||
"test:integration": "pnpm prune:integration && docker-compose -f integration-test.yml up --abort-on-container-exit --exit-code-from api-cli",
|
||||
"test:integration": "sh integration-test.sh",
|
||||
"test:unit": "cross-env NODE_CONFIG_ENV=elasticsearch ALLOW_NO_TRANSPORT=true STAPPS_LOG_LEVEL=0 mocha --exit"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -71,6 +72,7 @@
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openstapps/api-cli": "workspace:*",
|
||||
"@openstapps/eslint-config": "workspace:*",
|
||||
"@openstapps/prettier-config": "workspace:*",
|
||||
"@openstapps/tsconfig": "workspace:*",
|
||||
@@ -89,6 +91,7 @@
|
||||
"cross-env": "7.0.3",
|
||||
"get-port": "5.1.1",
|
||||
"mocha": "10.2.0",
|
||||
"mocha-junit-reporter": "2.2.0",
|
||||
"mocked-env": "1.3.5",
|
||||
"redoc-cli": "0.13.20",
|
||||
"sinon": "15.0.4",
|
||||
@@ -118,12 +121,5 @@
|
||||
"overrides": [
|
||||
"test"
|
||||
]
|
||||
},
|
||||
"pnpm": {
|
||||
"peerDependencyRules": {
|
||||
"allowedVersions": {
|
||||
"rxjs": "7.x"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"extends": ["//"],
|
||||
"pipeline": {
|
||||
"TODO:test:integration": {
|
||||
"dependsOn": [
|
||||
"@openstapps/database#build:docker",
|
||||
"@openstapps/backend#build:docker",
|
||||
"@openstapps/api-cli#build:docker"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@
|
||||
"c8": "7.14.0",
|
||||
"chai": "4.3.7",
|
||||
"mocha": "10.2.0",
|
||||
"mocha-junit-reporter": "2.2.0",
|
||||
"sinon": "15.0.4",
|
||||
"sinon-chai": "3.7.0",
|
||||
"ts-node": "10.9.1",
|
||||
|
||||
Reference in New Issue
Block a user