vps 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 19a1e8448e7c6d7549da881d3c4410dffd9eee99
4
- data.tar.gz: 8ed547a6a851bfc83a7be9df20d8781d8bf39d6b
3
+ metadata.gz: 933bc1ae373f67158e536ef0f9fba44ce4dc7173
4
+ data.tar.gz: 4dc3addd296f9b7d7fd836ff3a82262572b21344
5
5
  SHA512:
6
- metadata.gz: 589a2204c45d5eb76a578258d6ac56b053f7efd99fec980ed81b8b9f58e2d86d25918ddd0eff90cb91be63ba1d5f0bae4b26e9bedb7636d264a1e6c377693391
7
- data.tar.gz: 477b312e229c9cef09c4f75a9e7e8f0aff05be8d9882940b9c03721049563addc569ace2c57739cb73c4a32390c8fdd78f8743af161037183be871745652d791
6
+ metadata.gz: 7eb4e3894ac019a90d984987761c5f03e57f1bdf35f9417bb1aa1df4ec817c9d3071d8715217516b4a6e0da237a0ddc9baacd413e807746ed243205f9ee256b7
7
+ data.tar.gz: c913b9fd13f1180e99dfda46425187f7989064d5ba19c021f24d9913a89123b4a381b3aa4ce45fc708440d83c36d046e79aff86a42df1ac6c1c367d689549c6a
@@ -1,5 +1,11 @@
1
1
  ## VPS CHANGELOG
2
2
 
3
+ ### Version 0.2.1 (January 2, 2020)
4
+
5
+ * Support NodeJS based applications
6
+ * Clean up default upstream specs
7
+ * Set container name when adding upstream
8
+
3
9
  ### Version 0.2.0 (December 31, 2019)
4
10
 
5
11
  * Provide ability to add both custom HTTP and HTTPS Nginx configs
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.1
data/lib/vps.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "tmpdir"
1
2
  require "vps/version"
2
3
 
3
4
  module VPS
@@ -11,7 +11,7 @@ module VPS
11
11
 
12
12
  if (upstream = config[:upstreams].detect{|upstream| upstream[:name] == name})
13
13
  upstream[:email] = email if email
14
- upstream[:domains].push(domain).uniq!
14
+ (upstream[:domains] ||= []).push(domain).uniq!
15
15
  VPS.write_config(host, config)
16
16
  end
17
17
  end
@@ -10,16 +10,12 @@ module VPS
10
10
 
11
11
  unless config[:upstreams].any?{|upstream| upstream[:name] == name}
12
12
  spec = derive_upstream(path)
13
- spec[:nginx] ||= {
14
- :http => nil,
15
- :https => nil
16
- }
17
13
  config[:upstreams].push(spec.merge({
18
14
  :name => name || File.basename(path),
19
15
  :path => path,
20
- :domains => [],
21
- :email => nil,
22
- :compose => nil
16
+ :compose => {
17
+ :container_name => name || File.basename(path)
18
+ }
23
19
  }))
24
20
  VPS.write_config(host, config)
25
21
  end
@@ -87,6 +83,20 @@ module VPS
87
83
  }
88
84
  end
89
85
  end
86
+ elsif Dir["#{path}/package.json"].any?
87
+ tmpfile = "#{Dir.tmpdir}/vps-debug.log"
88
+ pid = spawn("cd #{path} && npm start", :out => tmpfile, :err => "/dev/null")
89
+ Process.detach(pid)
90
+ sleep 5
91
+ `ps aux | grep -e "no[d]e #{path}"`.strip.split("\n").collect do |line|
92
+ `kill -9 #{line.split(" ")[1]}`
93
+ end
94
+ port = File.read(tmpfile).match(/on port (\d+)/).captures.first.to_i
95
+ {
96
+ type: "node",
97
+ node_version: `$SHELL -l -c 'cd #{path} && node -v'`.match(/[\d\.?]+/).to_s,
98
+ port: port
99
+ }
90
100
  end
91
101
  end
92
102
 
@@ -1,7 +1,7 @@
1
1
  module VPS
2
2
  MAJOR = 0
3
3
  MINOR = 2
4
- TINY = 0
4
+ TINY = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, TINY].join(".")
7
7
  end
@@ -0,0 +1,12 @@
1
+ FROM node:<%= upstream.node_version %>-alpine
2
+
3
+ RUN apk update \
4
+ && apk --no-cache --update add \
5
+ build-base nodejs tzdata
6
+
7
+ WORKDIR /opt/app
8
+ COPY . .
9
+
10
+ ENV NODE_ENV=production
11
+ RUN npm install
12
+ CMD ["npm", "start"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Engel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2020-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -174,6 +174,7 @@ files:
174
174
  - script/console
175
175
  - templates/docker/data/nginx/app.conf.erb
176
176
  - templates/docker/docker-compose.yml.erb
177
+ - templates/docker/upstream/Dockerfile.node.erb
177
178
  - templates/docker/upstream/Dockerfile.phoenix.erb
178
179
  - templates/docker/upstream/Dockerfile.plug.erb
179
180
  - templates/docker/upstream/Dockerfile.rack.erb