如何从容器获取目录到travis-ci工作目录?

时间:2019-01-15 19:30:04

标签: reactjs docker travis-ci github-pages

当travis-ci在Docker容器中构建我的应用程序时出现错误。构建文件夹没有关闭。这是错误日志

Deploying application
Initialized empty Git repository in /tmp/d20190115-5107- 
1w5c6ge/work/.git/
Switched to a new branch 'gh-pages'
cd -
cd /tmp/d20190115-5107-1w5c6ge/work
rsync: change_dir "/app/build" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) 
(code 23) at main.c(1183) [sender=3.1.0]
Could not copy /app/build.

这是我的.travis.yml和dockerfile。

# Grants super user permissions
sudo: required

# travis ci installs docker into travis container
services:
  - docker
# before tests are ran build docker image
before_install:
  - docker build -t dvontrec/fn-killers -f Dockerfile.dev .
script:
  # SHOULD ADD TESTS
  - docker run dvontrec/fn-killers pwd
  - docker run dvontrec/fn-killers ls
# Steps before deploy:
defore_deploy:
  - docker run dvontrec/fn-killers -f npm run build
# Steps to deploy to github pages
deploy:
  provider: pages
  skip_cleanup: true
  github_token: $github_token
  on:
    branch: master
FROM node:alpine

WORKDIR './app'

COPY package.json .
RUN npm install 

COPY . .
CMD ["npm", "run", "start-docker"]

有人知道如何从容器中提取文件吗?

1 个答案:

答案 0 :(得分:1)

我发现我做错了什么,要使用docker进行部署,您需要有一个nginx容器,该容器可以将所有内容复制下来。这是我使用的Dockerfile。

# Build phase
FROM node:alpine as builder
WORKDIR '/app'
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

# Run phase
FROM nginx
EXPOSE 80
COPY --from=builder /app/build /usr/share/nginx/html