yatfa 1.0.72 → 1.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install-agent.sh +1 -1
- package/lib/yatfa_agent/docker.rb +51 -2
- package/package.json +1 -1
package/bin/install-agent.sh
CHANGED
|
@@ -7,7 +7,7 @@ export DEBIAN_FRONTEND=noninteractive
|
|
|
7
7
|
echo 'Acquire::Check-Date "false";' > /etc/apt/apt.conf.d/99no-check-date
|
|
8
8
|
|
|
9
9
|
apt-get update && apt-get install -y \
|
|
10
|
-
git curl tmux sudo unzip wget jq nano
|
|
10
|
+
git curl tmux sudo unzip wget jq nano chromium
|
|
11
11
|
|
|
12
12
|
# Install Node.js (required for Claude CLI)
|
|
13
13
|
# Check for existing Node installation
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "fileutils"
|
|
4
|
+
require "net/http"
|
|
5
|
+
require "json"
|
|
6
|
+
require "uri"
|
|
4
7
|
|
|
5
8
|
module YatfaAgent
|
|
6
9
|
module Docker
|
|
10
|
+
STAMP_FILE = ".yatfa-build-stamp"
|
|
11
|
+
VERSION_URL = "https://objectstore.fra1.civo.com/yatfa/main/version.json"
|
|
12
|
+
|
|
7
13
|
def self.check_dockerfile!
|
|
8
14
|
unless File.exist?("Dockerfile.sandbox")
|
|
9
15
|
puts "❌ Error: Dockerfile.sandbox not found"
|
|
@@ -16,12 +22,50 @@ module YatfaAgent
|
|
|
16
22
|
end
|
|
17
23
|
end
|
|
18
24
|
|
|
25
|
+
def self.fetch_remote_version
|
|
26
|
+
uri = URI(VERSION_URL)
|
|
27
|
+
response = Net::HTTP.get_response(uri)
|
|
28
|
+
return nil unless response.is_a?(Net::HTTPSuccess)
|
|
29
|
+
data = JSON.parse(response.body)
|
|
30
|
+
data["deployed_at"]
|
|
31
|
+
rescue StandardError
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.read_build_stamp
|
|
36
|
+
return nil unless File.exist?(STAMP_FILE)
|
|
37
|
+
JSON.parse(File.read(STAMP_FILE))["version"]
|
|
38
|
+
rescue StandardError
|
|
39
|
+
nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.write_build_stamp(version)
|
|
43
|
+
File.write(STAMP_FILE, JSON.pretty_generate({ version: version, built_at: Time.now.utc.iso8601 }))
|
|
44
|
+
end
|
|
45
|
+
|
|
19
46
|
def self.build_image(config)
|
|
20
47
|
check_dockerfile!
|
|
21
48
|
|
|
22
49
|
user_id = `id -u`.strip
|
|
23
50
|
group_id = `id -g`.strip
|
|
24
51
|
|
|
52
|
+
# Check if we need to invalidate Docker cache based on remote version
|
|
53
|
+
remote_version = fetch_remote_version
|
|
54
|
+
local_version = read_build_stamp
|
|
55
|
+
no_cache = remote_version && remote_version != local_version
|
|
56
|
+
|
|
57
|
+
if no_cache
|
|
58
|
+
if local_version
|
|
59
|
+
puts "🔄 Infrastructure updated (#{local_version[0..18]} → #{remote_version[0..18]}), rebuilding without cache..."
|
|
60
|
+
else
|
|
61
|
+
puts "🔄 First build (or stamp missing), rebuilding without cache..."
|
|
62
|
+
end
|
|
63
|
+
elsif remote_version.nil?
|
|
64
|
+
puts "⚠️ Could not fetch remote version, building with cache"
|
|
65
|
+
else
|
|
66
|
+
puts "✅ Infrastructure up to date, using cached build"
|
|
67
|
+
end
|
|
68
|
+
|
|
25
69
|
puts "🏗️ Building Docker image..."
|
|
26
70
|
|
|
27
71
|
# Handle .dockerignore.sandbox
|
|
@@ -42,14 +86,16 @@ module YatfaAgent
|
|
|
42
86
|
|
|
43
87
|
success = false
|
|
44
88
|
begin
|
|
45
|
-
|
|
89
|
+
build_args = [
|
|
46
90
|
"docker", "build",
|
|
91
|
+
*(no_cache ? ["--no-cache"] : []),
|
|
47
92
|
"--build-arg", "USER_ID=#{user_id}",
|
|
48
93
|
"--build-arg", "GROUP_ID=#{group_id}",
|
|
49
94
|
"-t", Config.image_name(config),
|
|
50
95
|
"-f", "Dockerfile.sandbox",
|
|
51
96
|
"."
|
|
52
|
-
|
|
97
|
+
]
|
|
98
|
+
success = system(*build_args)
|
|
53
99
|
ensure
|
|
54
100
|
if has_sandbox_ignore
|
|
55
101
|
# Restore original state
|
|
@@ -66,6 +112,9 @@ module YatfaAgent
|
|
|
66
112
|
exit 1
|
|
67
113
|
end
|
|
68
114
|
|
|
115
|
+
# Write stamp after successful build so we know which version we have
|
|
116
|
+
write_build_stamp(remote_version) if remote_version
|
|
117
|
+
|
|
69
118
|
puts "✅ Docker image built"
|
|
70
119
|
end
|
|
71
120
|
end
|