Jekyll 的 Netlify 部署在使用 Docker Compose 时失败
Netlify deployment of Jekyll fails on using Docker Compose
我正在使用 docker-compose 构建我的 Jekyll 项目:
version: "3"
services:
site:
command: jekyll serve
image: jekyll/jekyll:latest
volumes:
- $PWD:/srv/jekyll
- $PWD/vendor/bundle:/usr/local/bundle
ports:
- 4000:4000
- 35729:35729
- 3000:3000
- 80:4000
文件夹结构看起来像
[projectname]/
├── mysite/
│ ├── .gitignore
│ ├── Gemfile
│ ├── vendor
│ └── [...]
├── docker-compose.yml
└── vendor
我现在正在尝试部署到 Netlify,但文件夹结构似乎带来了问题,因为它都在 mysite 下,而不是在上面的文件夹中。但是,通过使用 docker-compose,我不知道如何改变它。我在 Netlify 上部署时遇到的错误在这里:
11:08:51 AM: Preparing Git Reference refs/heads/master
11:08:52 AM: Starting build script
11:08:52 AM: Installing dependencies
11:08:54 AM: Downloading and installing node v8.12.0...
11:08:54 AM: Downloading https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz...
11:08:54 AM:
#
11:08:54 AM: 1.9%
11:08:54 AM:
#########################
11:08:54 AM: 35.1%
11:08:54 AM:
######################################
11:08:54 AM: ################ 76.1%
11:08:54 AM:
##################################################
11:08:54 AM: ###################### 100.0%
11:08:54 AM: Computing checksum with sha256sum
11:08:54 AM: Checksums matched!
11:08:56 AM: Now using node v8.12.0 (npm v6.4.1)
11:08:56 AM: Attempting ruby version 2.3.6, read from environment
11:08:57 AM: Using ruby version 2.3.6
11:08:57 AM: Using PHP version 5.6
11:08:57 AM: Started restoring cached go cache
11:08:57 AM: Finished restoring cached go cache
11:08:57 AM: unset GOOS;
11:08:57 AM: unset GOARCH;
11:08:57 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
11:08:57 AM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
11:08:57 AM: go version >&2;
11:08:57 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
11:08:57 AM: go version go1.10 linux/amd64
11:08:57 AM: Installing missing commands
11:08:57 AM: Verify run directory
11:08:57 AM: Executing user command: jekyll build
11:08:57 AM: /usr/local/bin/build: line 32: jekyll: command not found
11:08:57 AM: Caching artifacts
11:08:58 AM: Started saving pip cache
11:08:58 AM: Finished saving pip cache
11:08:58 AM: Started saving emacs cask dependencies
11:08:58 AM: Finished saving emacs cask dependencies
11:08:58 AM: Started saving maven dependencies
11:08:58 AM: Finished saving maven dependencies
11:08:58 AM: Started saving boot dependencies
11:08:58 AM: Finished saving boot dependencies
11:08:58 AM: Started saving go dependencies
11:08:58 AM: Finished saving go dependencies
11:08:58 AM: Cached node version v8.12.0
11:08:58 AM: Error running command: Build script returned non-zero exit code: 127
11:08:58 AM: Failing build: Failed to build site
11:08:58 AM: failed during stage 'building site': Build script returned non-zero exit code: 127
11:08:58 AM: Finished processing build request in 7.670431208s
Netlify 允许使用 netlify.toml
设置项目的 base
目录位置
netlify.toml
(需要在存储库的根目录中)
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = "project/"
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build.
publish = "project/build-output/"
了解其他选项 in the docs
另一种选择是将您的 mysite
文件夹移动到它自己的存储库,因为 Netlify 不需要 docker 配置来将环境设置为 运行 jekyll
因为默认支持。
我正在使用 docker-compose 构建我的 Jekyll 项目:
version: "3"
services:
site:
command: jekyll serve
image: jekyll/jekyll:latest
volumes:
- $PWD:/srv/jekyll
- $PWD/vendor/bundle:/usr/local/bundle
ports:
- 4000:4000
- 35729:35729
- 3000:3000
- 80:4000
文件夹结构看起来像
[projectname]/
├── mysite/
│ ├── .gitignore
│ ├── Gemfile
│ ├── vendor
│ └── [...]
├── docker-compose.yml
└── vendor
我现在正在尝试部署到 Netlify,但文件夹结构似乎带来了问题,因为它都在 mysite 下,而不是在上面的文件夹中。但是,通过使用 docker-compose,我不知道如何改变它。我在 Netlify 上部署时遇到的错误在这里:
11:08:51 AM: Preparing Git Reference refs/heads/master
11:08:52 AM: Starting build script
11:08:52 AM: Installing dependencies
11:08:54 AM: Downloading and installing node v8.12.0...
11:08:54 AM: Downloading https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz...
11:08:54 AM:
#
11:08:54 AM: 1.9%
11:08:54 AM:
#########################
11:08:54 AM: 35.1%
11:08:54 AM:
######################################
11:08:54 AM: ################ 76.1%
11:08:54 AM:
##################################################
11:08:54 AM: ###################### 100.0%
11:08:54 AM: Computing checksum with sha256sum
11:08:54 AM: Checksums matched!
11:08:56 AM: Now using node v8.12.0 (npm v6.4.1)
11:08:56 AM: Attempting ruby version 2.3.6, read from environment
11:08:57 AM: Using ruby version 2.3.6
11:08:57 AM: Using PHP version 5.6
11:08:57 AM: Started restoring cached go cache
11:08:57 AM: Finished restoring cached go cache
11:08:57 AM: unset GOOS;
11:08:57 AM: unset GOARCH;
11:08:57 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';
11:08:57 AM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";
11:08:57 AM: go version >&2;
11:08:57 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';
11:08:57 AM: go version go1.10 linux/amd64
11:08:57 AM: Installing missing commands
11:08:57 AM: Verify run directory
11:08:57 AM: Executing user command: jekyll build
11:08:57 AM: /usr/local/bin/build: line 32: jekyll: command not found
11:08:57 AM: Caching artifacts
11:08:58 AM: Started saving pip cache
11:08:58 AM: Finished saving pip cache
11:08:58 AM: Started saving emacs cask dependencies
11:08:58 AM: Finished saving emacs cask dependencies
11:08:58 AM: Started saving maven dependencies
11:08:58 AM: Finished saving maven dependencies
11:08:58 AM: Started saving boot dependencies
11:08:58 AM: Finished saving boot dependencies
11:08:58 AM: Started saving go dependencies
11:08:58 AM: Finished saving go dependencies
11:08:58 AM: Cached node version v8.12.0
11:08:58 AM: Error running command: Build script returned non-zero exit code: 127
11:08:58 AM: Failing build: Failed to build site
11:08:58 AM: failed during stage 'building site': Build script returned non-zero exit code: 127
11:08:58 AM: Finished processing build request in 7.670431208s
Netlify 允许使用 netlify.toml
base
目录位置
netlify.toml
(需要在存储库的根目录中)
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = "project/"
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build.
publish = "project/build-output/"
了解其他选项 in the docs
另一种选择是将您的 mysite
文件夹移动到它自己的存储库,因为 Netlify 不需要 docker 配置来将环境设置为 运行 jekyll
因为默认支持。