linchpin 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/bin/linchpin +5 -0
- data/lib/linchpin/cli.rb +75 -0
- data/lib/linchpin/dockerfiles/dotnet-Dockerfile.erb +33 -0
- data/lib/linchpin/templater.rb +18 -0
- data/lib/linchpin/version.rb +3 -0
- data/lib/linchpin.rb +1 -0
- data/linchpin.gemspec +22 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 01d00cb7a724031a2f6088ceb93bd87aa8388afc432bdd013d1d8eebded5e7fb
|
4
|
+
data.tar.gz: 5ee2d04f9fb92cff827187e671450849ef6d25c8dbb654b4eaf9fb1c0b053ea2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bda7fc3449a2de8ce51012ab3ac99b9acca41cf2bad6cb52ab6d93774eee9c62e9c19100df463a88b96d2ccc7912b04da4ccd807d8b562c00f41c1bf262bdfb3
|
7
|
+
data.tar.gz: 56519565545aacb6e1b9836fc27451507983fc94edddc5b1c5d676731a539123026db7a642a96374feb30ba1cf55946183a1daef2e0c15e9be36fccfba1f06c4
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.swp
|
19
|
+
.direnv
|
20
|
+
.envrc
|
21
|
+
|
22
|
+
test.rb
|
23
|
+
*.idea
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 DataConstruct Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# linchpin
|
data/bin/linchpin
ADDED
data/lib/linchpin/cli.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'linchpin/templater'
|
3
|
+
require 'shellwords'
|
4
|
+
require 'find'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
class LinchpinCLI < Thor
|
8
|
+
desc "build", "attempt to auto-discover application type and build it."
|
9
|
+
def build
|
10
|
+
app_type = discover_type(Dir.pwd)
|
11
|
+
app_name = discover_appname
|
12
|
+
case app_type
|
13
|
+
when 'dotnet'
|
14
|
+
puts "Building dotnet app #{app_name}"
|
15
|
+
build_dotnet(app_name, get_version_hash)
|
16
|
+
else
|
17
|
+
raise "Error: Could not build app type #{app_type}."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "push", "push artifact to repository"
|
22
|
+
def push
|
23
|
+
app_name = discover_appname
|
24
|
+
version = get_version_hash
|
25
|
+
escaped_command = Shellwords.escape("docker push dataconstruct/#{app_name}:#{version}")
|
26
|
+
command_output = system({}, "bash -c #{escaped_command}")
|
27
|
+
exit(1) unless command_output
|
28
|
+
end
|
29
|
+
private
|
30
|
+
|
31
|
+
def discover_type(root_dir)
|
32
|
+
'dotnet' if Dir["#{root_dir}/*.sln"].any?
|
33
|
+
end
|
34
|
+
|
35
|
+
def discover_appname
|
36
|
+
`basename \`git rev-parse --show-toplevel\``.strip
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_version_hash
|
40
|
+
`git rev-parse HEAD`.strip
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_dotnet(app_name, version)
|
44
|
+
entry_dir = ''
|
45
|
+
Find.find('./') do |path|
|
46
|
+
if path =~ /.*Program\.cs$/ and !path.include? 'common' and !path.include? 'obj'
|
47
|
+
puts "Found #{path}"
|
48
|
+
entry_dir = File.dirname(path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
entry_dll = ''
|
53
|
+
Find.find(entry_dir) do |path|
|
54
|
+
if path =~ /.*\.csproj$/
|
55
|
+
entry_dll = "#{File.basename(path, ".csproj")}.dll"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
file = Tempfile.new('Dockerfile')
|
61
|
+
dockerfile = file.path
|
62
|
+
file.write(Linchpin::Templater.new(entry_dll).render)
|
63
|
+
file.rewind # => "hello world"
|
64
|
+
file.close
|
65
|
+
|
66
|
+
puts "BUILDING #{app_name}:#{version}"
|
67
|
+
|
68
|
+
escaped_command = Shellwords.escape("docker build . -f #{dockerfile} -t dataconstruct/#{app_name}:#{version}")
|
69
|
+
command_output = system({}, "bash -c #{escaped_command}")
|
70
|
+
|
71
|
+
file.unlink
|
72
|
+
|
73
|
+
exit(1) unless command_output
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
FROM microsoft/dotnet:2.2.0-aspnetcore-runtime AS base
|
2
|
+
WORKDIR /app
|
3
|
+
EXPOSE 80
|
4
|
+
|
5
|
+
FROM microsoft/dotnet:2.2.100-sdk AS build
|
6
|
+
WORKDIR /src
|
7
|
+
COPY . .
|
8
|
+
RUN ls -la
|
9
|
+
# WORKDIR /src/Catalog.API
|
10
|
+
RUN dotnet restore -nowarn:msb3202,nu1503
|
11
|
+
# RUN dotnet build --no-restore -c Release -o /app
|
12
|
+
RUN dotnet build --no-restore -c Release
|
13
|
+
|
14
|
+
FROM build as unittest
|
15
|
+
WORKDIR /src/Catalog.UnitTests
|
16
|
+
|
17
|
+
FROM build as functionaltest
|
18
|
+
WORKDIR /src/Catalog.FunctionalTests
|
19
|
+
|
20
|
+
FROM build AS publish
|
21
|
+
RUN dotnet publish --no-restore -c Release -o bin/deploy
|
22
|
+
|
23
|
+
FROM base AS final
|
24
|
+
WORKDIR /app
|
25
|
+
COPY --from=publish /src/Catalog.API/bin/deploy .
|
26
|
+
RUN mkdir -p /opt/appdynamics/dotnet
|
27
|
+
ADD appd/libappdprofiler.so /opt/appdynamics/dotnet/
|
28
|
+
ADD appd/AppDynamics.Agent.netstandard.dll /opt/appdynamics/dotnet/
|
29
|
+
# Mandatory settings required to attach the agent to the .NET application
|
30
|
+
ENV CORECLR_PROFILER={57e1aa68-2229-41aa-9931-a6e93bbc64d8} \
|
31
|
+
CORECLR_ENABLE_PROFILING=1 \
|
32
|
+
CORECLR_PROFILER_PATH=/opt/appdynamics/dotnet/libappdprofiler.so
|
33
|
+
ENTRYPOINT ["dotnet", "<%= @entry_dll %>"]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'erb'
|
2
|
+
|
3
|
+
# Provides bindings for a template
|
4
|
+
module Linchpin
|
5
|
+
class Templater
|
6
|
+
include ERB::Util
|
7
|
+
|
8
|
+
def initialize(entry_dll)
|
9
|
+
@entry_dll = entry_dll
|
10
|
+
@template_loc = File.join(File.join(File.dirname(File.expand_path(__FILE__)), 'dockerfiles'),'dotnet-Dockerfile.erb')
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
template = ERB.new File.new(@template_loc).read, nil, '%'
|
15
|
+
template.result(binding)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/linchpin.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'linchpin/cli'
|
data/linchpin.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'linchpin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "linchpin"
|
8
|
+
spec.version = Linchpin::VERSION
|
9
|
+
spec.authors = ["Paul Everton"]
|
10
|
+
spec.email = ["Paul Everton"]
|
11
|
+
spec.description = "Linchpin will automatically figure out how to build and deploy your app!"
|
12
|
+
spec.summary = "Linchpin will automatically figure out how to build and deploy your app!"
|
13
|
+
spec.homepage = "https://github.com/DataConstruct/linchpin"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linchpin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Everton
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Linchpin will automatically figure out how to build and deploy your app!
|
28
|
+
email:
|
29
|
+
- Paul Everton
|
30
|
+
executables:
|
31
|
+
- linchpin
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- bin/linchpin
|
40
|
+
- lib/linchpin.rb
|
41
|
+
- lib/linchpin/cli.rb
|
42
|
+
- lib/linchpin/dockerfiles/dotnet-Dockerfile.erb
|
43
|
+
- lib/linchpin/templater.rb
|
44
|
+
- lib/linchpin/version.rb
|
45
|
+
- linchpin.gemspec
|
46
|
+
homepage: https://github.com/DataConstruct/linchpin
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.7.8
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Linchpin will automatically figure out how to build and deploy your app!
|
70
|
+
test_files: []
|