Tôi đang gỡ lỗi một vấn đề mà tôi đang phát triển bên trong vùng chứa Docker, nhưng Jekyll không cập nhật đúng tệp HTML hoặc CSS tĩnh sau lần đầu tiên bằng văn bản. Tôi đã thêm mã sau vào static_file.rb
sau dòng 83:jekyll không cập nhật CSS tĩnh, tệp HTML trong vùng chứa Docker phát triển
sha256_src = Digest::SHA256.file path
sha256_dst = Digest::SHA256.file dest_path
fail "invalid file copy: #{path}/#{dest_path}" unless sha256_src == sha256_dst
Và tôi thấy rằng lỗi được kích hoạt vì băm không khớp. Thay vào đó, phiên bản cũ của tệp tĩnh tại path
đã được sao chép sang dest_path
. Tôi nghĩ rằng tôi đã mất tâm trí của tôi, nhưng tôi biết rằng Docker sử dụng hệ thống tập tin lớp và vì vậy tôi tự hỏi nếu tôi nhấn một số loại lỗi hoặc vấn đề được biết đến.
Có bất kỳ vấn đề được biết đến với việc sử dụng các công nghệ sau song song với nhau:
- Jekyll
- container Docker container
- Linux
- FileUtils cp method
- của Ruby 2.2.3p173
tôi đã phải làm việc xung quanh nó bằng cách chạy lệnh sau:
cp s5/*.css _site/s5/
cp s5/*.html _site/s5/
Thay vì phải cho nó hoạt động tự động cho tôi với jekyll build
.
Sau đây là cách tôi đang liên kết tập tin của tôi với những hình ảnh Docker:
export ABSPATH=$(cd "$(dirname "$0")"; cd ../; pwd)
docker run -d --name static -t -i -p 4000:4000 -p 2422:22 --link static-db:db -v "$ABSPATH:/mnt/app" me/static:0.0.2 /sbin/my_init --enable-insecure-key
Docker phiên bản:
thông tinClient:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 18:01:15 UTC 2015
OS/Arch: darwin/amd64
Server:
Version: 1.8.3
API version: 1.20
Go version: go1.4.2
Git commit: f4bf5c7
Built: Mon Oct 12 18:01:15 UTC 2015
OS/Arch: linux/amd64
Docker:
Containers: 10
Images: 265
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 285
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.10-boot2docker
Operating System: Boot2Docker 1.8.3 (TCL 6.4); master : af8b089 - Mon Oct 12 18:56:54 UTC 2015
CPUs: 1
Total Memory: 3.859 GiB
Name: dev
ID: ZY6F:2VSO:EDRL:TWYE:JAS6:5GC3:PPAO:TNA6:KCCB:HFLC:4IQB:5BYE
Debug mode (server): true
File Descriptors: 21
Goroutines: 33
System Time: 2015-10-18T18:36:20.08630971Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Username: me
Registry: https://index.docker.io/v1/
Labels:
provider=virtualbox
Tôi đang chạy điều này được liên kết với một khối lượng trên OSX.
Đây là phiên tương tác sử dụng binding.pry bên trong static_file.rb. Bạn có thể thấy rằng FileUtils.cp không hoạt động đúng cách.
Trong bước 9-10 người ta có thể thấy tôi đang tự gọi lệnh FileUtils::cp
và băm tệp kết quả là aa75cd...
. Tôi thậm chí còn thử sử dụng FileUtils.cp
để sao chép tệp gốc của mình sang một đường dẫn tệp khác mà không thành công. Tuy nhiên, trong bước 20-21, khi tôi gọi lệnh shell cp trực tiếp bằng cách sử dụng cp
, nó hoạt động và tệp kết quả có hàm băm phù hợp là 724707...
.
Parsing Haml layouts...done.
Parsing Scss layouts...done.
Configuration file: /mnt/app/_config.yml
Source: /mnt/app
Destination: /mnt/app/_site
Generating...
From: /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-2.5.3/lib/jekyll/static_file.rb @ line 92 Jekyll::StaticFile#write:
77: def write(dest)
78: dest_path = destination(dest)
79:
80: return false if File.exist?(dest_path) and !modified?
81: @@mtimes[path] = mtime
82:
83: FileUtils.mkdir_p(File.dirname(dest_path))
84: FileUtils.rm(dest_path) if File.exist?(dest_path)
85:
86: FileUtils.cp(path, dest_path)
87:
88: sha256_src = Digest::SHA256.file path
89: sha256_dst = Digest::SHA256.file dest_path
90:
91: if sha256_src != sha256_dst
=> 92: binding.pry
93: end
94: puts "invalid file copy: #{path}/#{dest_path}" unless sha256_src == sha256_dst
95:
96: true
97: end
[1] pry(#<Jekyll::StaticFile>)> path
=> "/mnt/app/styles/scruff5.css"
[2] pry(#<Jekyll::StaticFile>)> dest_path
=> "/mnt/app/_site/styles/scruff5.css"
[3] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file path
=> #<Digest::SHA256: 72470716291c6fef0c8c2151a0d0997f0991396cda964ba48e3cbb65cc7f7908>
[4] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file dest_path
=> #<Digest::SHA256: aa75cd20ddf51b86ec2344002532f08891e05eb1a0a9f7e5f99d8fda05c5c920>
[5] pry(#<Jekyll::StaticFile>)> dest_path
=> "/mnt/app/_site/styles/scruff5.css"
[6] pry(#<Jekyll::StaticFile>)> FileUtils.rm(dest_path)
=> ["/mnt/app/_site/styles/scruff5.css"]
[7] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file dest_path
Errno::ENOENT: No such file or directory @ rb_sysopen - /mnt/app/_site/styles/scruff5.css
from /usr/local/lib/ruby/2.2.0/digest.rb:49:in `initialize'
[8] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file path
=> #<Digest::SHA256: 72470716291c6fef0c8c2151a0d0997f0991396cda964ba48e3cbb65cc7f7908>
[9] pry(#<Jekyll::StaticFile>)> FileUtils.cp(path, dest_path)
=> nil
[10] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file dest_path
=> #<Digest::SHA256: aa75cd20ddf51b86ec2344002532f08891e05eb1a0a9f7e5f99d8fda05c5c920>
[11] pry(#<Jekyll::StaticFile>)> dest_path
=> "/mnt/app/_site/styles/scruff5.css"
[12] pry(#<Jekyll::StaticFile>)> dest_path = dest_path + '-2'
=> "/mnt/app/_site/styles/scruff5.css-2"
[13] pry(#<Jekyll::StaticFile>)> FileUtils.cp(path, dest_path)
=> nil
[14] pry(#<Jekyll::StaticFile>)> FileUtils.cp(path, dest_path)
=> nil
[15] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file dest_path
=> #<Digest::SHA256: aa75cd20ddf51b86ec2344002532f08891e05eb1a0a9f7e5f99d8fda05c5c920>
[16] pry(#<Jekyll::StaticFile>)> (Digest::SHA256.file dest_path).hexdigest
=> "aa75cd20ddf51b86ec2344002532f08891e05eb1a0a9f7e5f99d8fda05c5c920"
[17] pry(#<Jekyll::StaticFile>)> (Digest::SHA256.file path).hexdigest
=> "72470716291c6fef0c8c2151a0d0997f0991396cda964ba48e3cbb65cc7f7908"
[18] pry(#<Jekyll::StaticFile>)> FileUtils.rm dest_path
=> ["/mnt/app/_site/styles/scruff5.css-2"]
[19] pry(#<Jekyll::StaticFile>)> dest_path = '/mnt/app/_site/styles/scruff5.css'
=> "/mnt/app/_site/styles/scruff5.css"
[20] pry(#<Jekyll::StaticFile>)> `cp #{path} #{dest_path}`
=> ""
[21] pry(#<Jekyll::StaticFile>)> Digest::SHA256.file dest_path
=> #<Digest::SHA256: 72470716291c6fef0c8c2151a0d0997f0991396cda964ba48e3cbb65cc7f7908>
[22] pry(#<Jekyll::StaticFile>)>
Bạn đang thêm tệp của mình vào vùng chứa/hình ảnh như thế nào? Nó được xây dựng như thế nào? Bạn có thể thêm đầu ra của 'docker version' và' docker info' không? – thaJeztah
@thaJeztah đã cập nhật câu trả lời của tôi và bao gồm một phiên làm việc tương tác khó hiểu nhất ... – esilver
Bạn đã thử khởi chạy máy chủ jekyll cục bộ, bên ngoài docker? Tiền thưởng của bạn nói rằng jekyll không thể sao chép các tập tin tĩnh "nữa". Bạn đã thực hiện những thay đổi nào đối với trang web, cấu hình jekyll hoặc môi trường của mình? – onebree