docker - 带有猫鼬的 GitLab CI Job NestJS 服务
问题描述
我正在尝试为 Gitlab Continuos 集成范围内的简单后端 NestJS 项目配置gitlab - ci.yml文件,该项目具有与 MongoDB 数据库保持一致的服务。
我也有一个角度客户端,之前我在 Gitlab 上正确安装了该客户端,我可以通过公共 GitLab 站点访问它。
我将这个gitlab-ci.yml文件用于后端项目。
image: node:14.15.0
stages:
- install
- test
- build
- deploy
install:
stage: install
script:
- npm install
artifacts:
expire_in: 1h
paths:
- node_modules/
cache:
paths:
- node_modules/
tests:
stage: test
dependencies:
- install
script:
- npm run test:ci
coverage: '/Statements.*?(\d+(?:\.\d+)?)%/'
build:
stage: build
variables:
BUILD_CONFIG: 'production'
dependencies:
- install
script:
- npm run build
artifacts:
expire_in: 1h
paths:
- dist/
only:
- master
pages:
stage: deploy
dependencies:
- build
script:
- npm i -g @nestjs/cli
- npm install
- nest start
artifacts:
paths:
- public/
environment:
name: production
only:
- master
此文件成功执行“安装、测试和构建”阶段,但在部署阶段失败,请参见图像。
正如您在启动后看到的那样,它尝试连接到 MongoDB 数据库并失败。
在部署阶段,我安装了NestJs模块并启动它,但我认为这不正确,正确的方法是为 NestJs 和 MongoDB 使用 Docker 映像,但我真的不知道如何在 GitLab 方面做到这一点。
所以我很感激任何帮助。
解决方案
推荐阅读
- java - 使用 JSON 和 volley 发送数据
- google-pagespeed - 灯塔:FAILED_DOCUMENT_REQUEST
- java - 我可以强制 maven 依赖项 A 使用特定版本的依赖项 B,同时使用不同版本的依赖项 B 吗?
- react-native - 具有相同动作的减速器影响多个屏幕
- robotframework - 如何在机器人框架中同时使用 And 和 Or 条件
- cakephp - cakephp:使用保存方法,我想在数据没有变化时更新修改时间
- css - Angular 在全局 style.css 文件中使用 CSS 变量
- go - Go 的 Echo 框架路由器问题?
- javascript - 在简单网站上显示生成的 JSON 文件
- neo4j - Cypher:如何优化浏览器中的搜索(可能使用参数)