Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 使用gitlab ci部署react应用程序的最佳方法?_Reactjs_Git_Docker_Gitlab_Gitlab Ci - Fatal编程技术网

Reactjs 使用gitlab ci部署react应用程序的最佳方法?

Reactjs 使用gitlab ci部署react应用程序的最佳方法?,reactjs,git,docker,gitlab,gitlab-ci,Reactjs,Git,Docker,Gitlab,Gitlab Ci,我刚刚开始了解gitlab CI/CD。我有自己的gitlab实例,还有两个Runner,一个共享,一个项目特定,都使用docker引擎 目前,我的暂存服务器是它自己的虚拟机,由docker compose托管。我通常使用裸git repo部署到此服务器,并将构建文件保存在git中 但是我想切换到CI/CD模型,所以我尝试将其作为我的.gitlab CI.yml: image: node stages: - build - stage build_frontend: stage: bui

我刚刚开始了解gitlab CI/CD。我有自己的gitlab实例,还有两个Runner,一个共享,一个项目特定,都使用docker引擎

目前,我的暂存服务器是它自己的虚拟机,由docker compose托管。我通常使用裸git repo部署到此服务器,并将构建文件保存在git中

但是我想切换到CI/CD模型,所以我尝试将其作为我的
.gitlab CI.yml

image: node

stages:
- build
- stage

build_frontend:
  stage: build
  script:
  - cd ./src/frontend
  - npm install && npm audit fix
  # CI=false set to ignore warnings as errors
  - CI=false npm run build
  artifacts:
    paths:
    - ./src/frontend/build
  tags:
  - projectname

但我对如何实际部署构建有点迷茫。最好的方法是将文件放到临时服务器(它只是一个VM)上。

您可以从GitLab本身如何使用自己的CI中获得一些线索,如“”:

他们有一个专门的部署步骤:

build site:
  image: node:6
  stage: build
  script:
    - npm install --progress=false
    - npm run build
  artifacts:
    expire_in: 1 week
    paths:
      - dist

unit test:
  image: node:6
  stage: test
  script:
    - npm install --progress=false
    - npm run unit

deploy:
  image: alpine
  stage: deploy
  script:
    - apk add --no-cache rsync openssh
    - mkdir -p ~/.ssh
    - echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa
    - chmod 600 ~/.ssh/id_dsa
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    - rsync -rav --delete dist/ user@server.com:/your/project/path/

因此,如果您可以打包和scp您的应用程序,您可以将其部署到您的虚拟机。

这里的dist是什么?@ZOthix作业工件的路径: