मैं एक समस्या को डीबग कर रहा हूं जहां मैं Docker कंटेनर के अंदर अपना विकास कर रहा हूं, लेकिन Jekyll पहली बार स्थिर HTML या CSS फ़ाइलों को ठीक से अपडेट नहीं कर रहा है लिखा हुआ। मैं रेखा 83 के बाद static_file.rb
के लिए निम्न कोड जोड़ लिया है:jekyll स्थिर सीएसएस को अद्यतन नहीं कर रहा है, डॉकर विकास कंटेनर में एचटीएमएल फाइलें
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
और मुझे लगता है कि क्योंकि हैश से मेल नहीं खाता चालू होने में विफल। इसके बजाए, path
पर स्थिर फ़ाइल का पुराना संस्करण dest_path
पर कॉपी किया गया है। मैंने सोचा कि मैं अपना दिमाग खो रहा था, लेकिन मुझे पता है कि डॉकर स्तरित फाइल सिस्टम का उपयोग करता है और इसलिए मुझे आश्चर्य है कि मैं किसी प्रकार की बग या ज्ञात समस्या को मार रहा हूं।
वहाँ रहे हैं एक दूसरे के साथ मिलकर निम्नलिखित प्रौद्योगिकियों का उपयोग के साथ किसी भी ज्ञात समस्याओं: रूबी 2.2.3p173
- Jekyll
- डोकर कंटेनर
- लिनक्स कंटेनर
- FileUtils cp method
मैं निम्न आदेश चलाकर यह हल करने के लिए किया है:
cp s5/*.css _site/s5/
cp s5/*.html _site/s5/
इसके बजाय यह jekyll build
साथ मेरे लिए स्वचालित रूप से काम होने की।
यहाँ है कि कैसे मैं डोकर छवि के लिए अपनी फ़ाइलें जोड़ने हूँ:
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
डोकर संस्करण:
Client:
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
डोकर जानकारी:
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
मैं चला रहा हूँ यह ओएसएक्स पर एक वॉल्यूम से जुड़ा हुआ है।
static_file.rb के अंदर binding.pry का उपयोग करके एक इंटरैक्टिव सत्र है। आप देख सकते हैं कि FileUtils.cp ठीक से काम नहीं कर रहा है।
चरण 9-10 में कोई देख सकता है कि मैं मैन्युअल रूप से FileUtils::cp
कमांड का आविष्कार कर रहा हूं, और परिणामी फ़ाइल हैश aa75cd...
है। मैं अपनी मूल फ़ाइल को सफलता के बिना किसी भिन्न फ़ाइल पथ पर कॉपी करने के लिए FileUtils.cp
का उपयोग करने का भी प्रयास करता हूं। हालांकि, चरण 20-21 में, जब मैं सीधे cp
का उपयोग कर खोल सीपी कमांड का आह्वान करता हूं, तो यह काम करता है और परिणामी फ़ाइल में 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>)>
आप अपनी फाइलें कंटेनर/छवि में कैसे जोड़ रहे हैं? यह कैसे बनाया गया है? क्या आप 'डॉकर संस्करण' और 'डॉकर जानकारी' का आउटपुट जोड़ सकते हैं? – thaJeztah
@thaJeztah ने मेरा उत्तर अपडेट किया और सबसे परेशान इंटरैक्टिव बाइंडिंग.pry सत्र शामिल किया ... – esilver
क्या आपने डॉकर के बाहर स्थानीय रूप से जेकिल सर्वर लॉन्च करने का प्रयास किया है? आपका बक्षीस कहता है कि जेकिल स्थिर फाइलों को "अब और" कॉपी नहीं कर सकता है। आपने अपनी साइट, जेकिल कॉन्फ़िगरेशन या पर्यावरण में क्या परिवर्तन किए हैं? – onebree