drocker 0.3.0
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 +10 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +18 -0
- data/Guardfile +71 -0
- data/README.md +52 -0
- data/Rakefile +12 -0
- data/cucumber.yml +2 -0
- data/drocker.gemspec +29 -0
- data/exe/dr +160 -0
- data/images/base-multi/Dockerfile +8 -0
- data/images/base/Dockerfile +25 -0
- data/images/desktop/Dockerfile +37 -0
- data/images/desktop/init.sh +13 -0
- data/images/emacs/Dockerfile +11 -0
- data/images/fontcustom/Dockerfile +27 -0
- data/images/office/Dockerfile +6 -0
- data/images/playonlinux/Dockerfile +24 -0
- data/images/rbenv/Dockerfile +21 -0
- data/images/ruby-build/Dockerfile +11 -0
- data/images/ruby/Dockerfile +10 -0
- data/images/ruby/README +1 -0
- data/images/vpn/Dockerfile +29 -0
- data/lib/drocker.rb +10 -0
- data/lib/drocker/image.rb +129 -0
- data/lib/drocker/mount.rb +14 -0
- data/lib/drocker/version.rb +3 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34f9a8c59ad916207e5b0493fd3a0abb5dfe689a9bb2acaa75fcd7def378ec0b
|
4
|
+
data.tar.gz: a2b0bf48d6f337f0003f48b547bd6ed8f2752ce16df09b7752aa673c1772b847
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ce7570901751fdd94da726a05ba48983be4187a2c46d1ab89acdb2126a38ccc12bce54426370105be042c402871552b7f5bda1411c23ade7e70524982c6483d
|
7
|
+
data.tar.gz: 9447119a260d85f08f5bfcd24602fc57a1e9efa9c681c1d99f46651f10897370638b11fac603961b12e52bb120107d7d046d025ea359f9c017906bb265aac4a1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
source "https://rubygems.org"
|
3
|
+
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
7
|
+
|
8
|
+
# gem "rails"
|
9
|
+
|
10
|
+
group(:test) do
|
11
|
+
gem "aruba", "~> 1.0"
|
12
|
+
gem "rake", "~> 13.0"
|
13
|
+
gem "rspec", "~> 3.10"
|
14
|
+
gem "pry", "~> 0.13.1"
|
15
|
+
end
|
16
|
+
|
17
|
+
gem "optparse", "~> 0.1.0"
|
18
|
+
gem "activesupport", "~> 6.0"
|
data/Guardfile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
cucumber_options = {
|
46
|
+
# Below are examples overriding defaults
|
47
|
+
|
48
|
+
# cmd: 'bin/cucumber',
|
49
|
+
# cmd_additional_args: '--profile guard',
|
50
|
+
# cmd_additional_args: '--profile default'
|
51
|
+
cmd_additional_args: '',
|
52
|
+
|
53
|
+
# all_after_pass: false,
|
54
|
+
all_on_start: false,
|
55
|
+
# keep_failed: false,
|
56
|
+
# feature_sets: ['features/frontend', 'features/experimental'],
|
57
|
+
|
58
|
+
# run_all: { cmd_additional_args: '--profile guard_all' },
|
59
|
+
focus_on: 'wip'
|
60
|
+
# notification: false
|
61
|
+
}
|
62
|
+
|
63
|
+
guard "cucumber", cucumber_options do
|
64
|
+
watch(%r{^exe/.+$})
|
65
|
+
watch(%r{^features/.+\.feature$})
|
66
|
+
watch(%r{^features/support/.+$}) { "features" }
|
67
|
+
|
68
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
|
69
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "features"
|
70
|
+
end
|
71
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Drocker
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/drocker`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'drocker'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install drocker
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
use this to avoid using bundle exec: https://github.com/ianheggie/rbenv-binstubs#readme
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/drocker.
|
39
|
+
|
40
|
+
## Prerequisits
|
41
|
+
|
42
|
+
.ruby-version
|
43
|
+
Gemfile
|
44
|
+
|
45
|
+
## Command
|
46
|
+
|
47
|
+
```
|
48
|
+
dr bash
|
49
|
+
dr rake
|
50
|
+
dr rails
|
51
|
+
dr bundle
|
52
|
+
dr rspec
|
data/Rakefile
ADDED
data/cucumber.yml
ADDED
data/drocker.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require_relative 'lib/drocker/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "drocker"
|
6
|
+
spec.version = Drocker::VERSION
|
7
|
+
spec.authors = ["Flavio"]
|
8
|
+
spec.email = ["flavio.pellanda@gmx.ch"]
|
9
|
+
|
10
|
+
spec.summary = %q{Include features into Dockerfiles}
|
11
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
12
|
+
spec.homepage = "https://github.com/fpellanda/drocker"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = spec.homepage + 'CHANGELOG.md'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
end
|
data/exe/dr
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'drocker'
|
4
|
+
require 'optparse'
|
5
|
+
require 'pathname'
|
6
|
+
require 'logger'
|
7
|
+
$log = Logger.new(STDOUT)
|
8
|
+
require 'active_support/all'
|
9
|
+
|
10
|
+
options = {}
|
11
|
+
version, ssh, image_name, keep, x, host, privileged, home, no_cache = nil
|
12
|
+
$dryrun = false
|
13
|
+
tmp = Pathname.new('tmp/dr')
|
14
|
+
|
15
|
+
docker_args = []
|
16
|
+
args = OptionParser.new do |o|
|
17
|
+
o.on('--image IMAGE', 'Build image with this name. If the name is a builtin image (see below), only the base image will be built') { |arg| image_name = arg }
|
18
|
+
o.on('--keep', 'Keep intermediate docker layer on build or keep created container after exit') { |arg| keep = true }
|
19
|
+
o.on('--ssh', 'Mount ssh-agent into container (file in env variable SSH_AUTH_SOCK)') { ssh = true }
|
20
|
+
o.on('-x', '--forward-x11', 'Mount /tmp/.X11-unix into container to start X applications on your screen') { x = true }
|
21
|
+
o.on('--host', 'Add --privileged and --network host to docker run') { host = true }
|
22
|
+
o.on('--home', 'Mount HOME to /home/docker/home') { home = true }
|
23
|
+
o.on('--privileged', 'Add --privileged to docker run') { privileged = true }
|
24
|
+
o.on('--no-cache', 'Add --no-cache to docker build') { no_cache = true }
|
25
|
+
o.on('--no-tty', 'Dont add -it to docker run') { options[:no_tty] = true }
|
26
|
+
o.on('--no-app-volume', 'Dont mount current path to /home/docker') { options[:no_app_volume] = true }
|
27
|
+
o.on('--docker-arg ARG', 'Add those arguments to docker run') {|arg| docker_args.push(arg) }
|
28
|
+
o.on('--dryrun', 'Dont build image, only print what would be built') {|arg| $dryrun = true }
|
29
|
+
o.on('--version', 'Print current drocker version') { puts "drocker version: #{Drocker::VERSION}"; exit 0 }
|
30
|
+
o.on('-h', '--help', 'Prints this help') {
|
31
|
+
puts '', o, ''
|
32
|
+
puts 'Built in images: ' + Drocker::Image.images_path.children.map(&:basename).sort.join(', ')
|
33
|
+
puts 'You can build on these images with DR_FROM'
|
34
|
+
puts
|
35
|
+
exit 0
|
36
|
+
}
|
37
|
+
end.parse!
|
38
|
+
|
39
|
+
command = args.first.try(&:to_sym)
|
40
|
+
|
41
|
+
path = nil
|
42
|
+
if image_name
|
43
|
+
base_image_path = Drocker::Image.images_path + image_name.split(':')[0]
|
44
|
+
if base_image_path.exist?
|
45
|
+
$log.info("Image #{image_name} is a base image. Using baseimage Dockerfile in #{base_image_path.to_s}")
|
46
|
+
path = base_image_path
|
47
|
+
end
|
48
|
+
end
|
49
|
+
image = Drocker::Image.new(name: image_name, path: path)
|
50
|
+
$log.info("Imagename: #{image.docker_image_name}")
|
51
|
+
|
52
|
+
def exec(args)
|
53
|
+
$log.info("Execute: #{args.inspect}")
|
54
|
+
Kernel.exec(*args)
|
55
|
+
end
|
56
|
+
|
57
|
+
$log.info("Command: #{command.inspect}")
|
58
|
+
case command
|
59
|
+
when :clean
|
60
|
+
dangling = %x{docker images -a --filter dangling=true -q}.split("\n")
|
61
|
+
puts 'Remove dangling images'
|
62
|
+
puts dangling
|
63
|
+
exec %w{docker rmi} + dangling
|
64
|
+
when :info, :inspect
|
65
|
+
exec %w{docker inspect} + [image.docker_image_name]
|
66
|
+
when :build
|
67
|
+
def build_with_dependencies!(image, options = {})
|
68
|
+
if image.docker_image_exist?
|
69
|
+
$log.info("Image exist #{image.docker_image_name}. Done.")
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
build_with_dependencies!(image.parent, options) if image.drocker_dependant?
|
74
|
+
|
75
|
+
if !image.dockerfile.exist?
|
76
|
+
$log.info("#{image} has no Dockerfile.")
|
77
|
+
return
|
78
|
+
end
|
79
|
+
|
80
|
+
FileUtils.cd(image.path) do
|
81
|
+
$log.info("Building #{image}...")
|
82
|
+
command = image.build_command(options)
|
83
|
+
command += options[:docker_args] || []
|
84
|
+
$log.info('Building with: ' + command.inspect)
|
85
|
+
next if $dryrun
|
86
|
+
throw "Image #{image} build failed" unless system(*command)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
build_with_dependencies!(image, keep: keep, no_cache: no_cache, docker_args: docker_args)
|
91
|
+
exit 0
|
92
|
+
when :rebuild
|
93
|
+
command = image.build_command(keep: keep, no_cache: no_cache)
|
94
|
+
throw "Image #{image} build failed" unless system(*command)
|
95
|
+
when :env
|
96
|
+
puts image.env
|
97
|
+
else
|
98
|
+
app_path = Pathname.new('.').realpath
|
99
|
+
|
100
|
+
mount = image.env_hash["MOUNT"]
|
101
|
+
if mount
|
102
|
+
origin = app_path + 'tmp/dr/mounts' + mount
|
103
|
+
origin.mkpath
|
104
|
+
docker_args += %W(--volume #{origin}:/home/docker/#{mount}:rw)
|
105
|
+
end
|
106
|
+
|
107
|
+
unless image.dockerfile.exist?
|
108
|
+
image = image.parent
|
109
|
+
end
|
110
|
+
|
111
|
+
if ssh
|
112
|
+
throw 'No agent running' unless ENV['SSH_AUTH_SOCK']
|
113
|
+
docker_args += ['--volume', "#{ENV['SSH_AUTH_SOCK']}:/home/docker/ssh-agent", '--env', 'SSH_AUTH_SOCK=/home/docker/ssh-agent']
|
114
|
+
end
|
115
|
+
|
116
|
+
tmp.mkpath
|
117
|
+
bundle = Pathname.new('tmp/dr/bundle')
|
118
|
+
bundle.mkpath
|
119
|
+
|
120
|
+
docker_args.push('--rm') unless keep
|
121
|
+
if x
|
122
|
+
raise 'No DISPLAY env set' unless ENV['DISPLAY']
|
123
|
+
docker_args += %W(-e DISPLAY=#{ENV['DISPLAY']})
|
124
|
+
|
125
|
+
x_socket = Pathname.new('/tmp/.X11-unix')
|
126
|
+
raise "#{x_socket} does not exist" unless x_socket.exist?
|
127
|
+
docker_args += %W(-v #{x_socket}:#{x_socket})
|
128
|
+
end
|
129
|
+
|
130
|
+
if !options[:no_app_volume]
|
131
|
+
docker_args += %W(--volume #{app_path}/:/home/docker/app)
|
132
|
+
end
|
133
|
+
|
134
|
+
docker_args += %W(--network host) if host
|
135
|
+
docker_args += %W(--privileged) if host or privileged
|
136
|
+
docker_args += %W(--volume #{ENV['HOME']}:/home/docker/home) if home
|
137
|
+
|
138
|
+
if false
|
139
|
+
docker_args += %W(--volume #{app_path}/tmp/dr:/home/docker/app/tmp:rw)
|
140
|
+
docker_args += %W(--volume #{app_path}/tmp/dr/bundle:/home/docker/app/.bundle)
|
141
|
+
docker_args += %w(--volume /home/local/git/libisi:/home/docker/libisi)
|
142
|
+
docker_args += %w(--volume /home/local/git/drocker:/home/docker/drocker)
|
143
|
+
|
144
|
+
docker_args += %w(--cap-add=NET_ADMIN --device=/dev/net/tun)
|
145
|
+
end
|
146
|
+
|
147
|
+
BUNDLE_COMMANDS = %w(rails rspec rake)
|
148
|
+
if BUNDLE_COMMANDS.include?(args.first)
|
149
|
+
args = %w(bundle exec) + args
|
150
|
+
end
|
151
|
+
|
152
|
+
args = %w(bash -l -c) + [(args).join(' ')] if args.present?
|
153
|
+
|
154
|
+
docker_args += %W(--hostname #{image.name})
|
155
|
+
|
156
|
+
if !options[:no_tty] || STDIN.tty?
|
157
|
+
docker_args.push('-it')
|
158
|
+
end
|
159
|
+
exec %w{docker run} + docker_args + [image.docker_image_name] + args
|
160
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ARG VERSION
|
2
|
+
FROM ubuntu:$VERSION
|
3
|
+
|
4
|
+
DR_SETUID
|
5
|
+
DR_SETGID
|
6
|
+
|
7
|
+
ENV HOME /home/docker
|
8
|
+
|
9
|
+
ENV DEBIAN_FROMTEND noninteractive
|
10
|
+
|
11
|
+
RUN apt-get update -y
|
12
|
+
RUN apt-get upgrade -y
|
13
|
+
RUN apt-get install -y bash sudo
|
14
|
+
|
15
|
+
# docker user
|
16
|
+
RUN apt-get install -y manpages inetutils-ping vim
|
17
|
+
RUN addgroup --gid $GID docker
|
18
|
+
RUN adduser --disabled-password --uid $UID --gid $GID --gecos '' docker
|
19
|
+
RUN adduser docker sudo
|
20
|
+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
|
21
|
+
USER docker
|
22
|
+
|
23
|
+
SHELL [ "bash", "-l", "-c" ]
|
24
|
+
|
25
|
+
WORKDIR $HOME
|
@@ -0,0 +1,37 @@
|
|
1
|
+
DR_FROM base
|
2
|
+
|
3
|
+
USER root
|
4
|
+
|
5
|
+
RUN apt-get install -y openssh-server
|
6
|
+
RUN echo X11Forwarding yes >> /etc/ssh/ssh_config
|
7
|
+
|
8
|
+
RUN apt-get install -y xterm
|
9
|
+
|
10
|
+
RUN apt-get install -y awesome libcairo-gobject2
|
11
|
+
|
12
|
+
# RUN apt-get install -y apt-transport-https ca-certificates
|
13
|
+
# RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
14
|
+
# RUN echo 'deb https://apt.dockerproject.org/repo ubuntu-$(lsb_release -cs) main' >> /etc/apt/sources.list.d/docker.list
|
15
|
+
# RUN apt-get update
|
16
|
+
# RUN apt-get install -y docker-engine
|
17
|
+
|
18
|
+
# RUN sudo apt-get update
|
19
|
+
# RUN sudo DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
|
20
|
+
# RUN curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
|
21
|
+
# RUN sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
22
|
+
# RUN sudo apt-get update
|
23
|
+
# RUN apt-cache policy docker-ce
|
24
|
+
# RUN sudo apt-get install -y docker-ce
|
25
|
+
|
26
|
+
RUN mkdir /var/run/sshd
|
27
|
+
|
28
|
+
EXPOSE 22
|
29
|
+
|
30
|
+
|
31
|
+
RUN apt-get install -y dos2unix
|
32
|
+
ADD init.sh .
|
33
|
+
RUN dos2unix init.sh
|
34
|
+
|
35
|
+
USER docker
|
36
|
+
|
37
|
+
CMD ["/bin/bash", "init.sh"]
|
@@ -0,0 +1,11 @@
|
|
1
|
+
DR_FROM base-multi
|
2
|
+
|
3
|
+
RUN sudo apt-get update
|
4
|
+
RUN sudo apt-get install -y build-essential git
|
5
|
+
RUN git clone git://git.savannah.gnu.org/emacs.git
|
6
|
+
RUN sudo apt-get install build-essential git autoconf texinfo libxaw7-dev libxpm-dev libpng12-dev libjpeg-dev libtiff4-dev libgif-dev libncurses5-dev libxpm-dev libdbus-1-dev libgtk-3-dev w3m w3m-img -y
|
7
|
+
RUN sudo mkdir -p /usr/share/deepin-emacs/common
|
8
|
+
RUN cd ./emacs-git && ./autogen.sh
|
9
|
+
RUN ./configure --prefix=/usr/share/deepin-emacs/common --with-x-toolkit=gtk3 && make && sudo make install
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
DR_FROM ruby:2.3.3
|
2
|
+
|
3
|
+
RUN sudo apt-get update
|
4
|
+
RUN sudo apt-get -y install fontforge wget unzip zlib1g-dev
|
5
|
+
|
6
|
+
# install of fontforge https://github.com/fontforge/fontforge/blob/master/INSTALL-git.md
|
7
|
+
RUN sudo apt-get -y install packaging-dev pkg-config python-dev libpango1.0-dev libglib2.0-dev libxml2-dev giflib-dbg libjpeg-dev libtiff-dev uthash-dev libspiro-dev build-essential automake flex bison
|
8
|
+
RUN sudo apt-get -y install unifont
|
9
|
+
|
10
|
+
RUN git clone https://github.com/fontforge/fontforge.git
|
11
|
+
|
12
|
+
WORKDIR $HOME/fontforge
|
13
|
+
RUN ./bootstrap;
|
14
|
+
RUN ./configure;
|
15
|
+
RUN make;
|
16
|
+
RUN sudo make install;
|
17
|
+
RUN sudo ldconfig;
|
18
|
+
WORKDIR $HOME
|
19
|
+
|
20
|
+
#RUN git clone https://github.com/FontCustom/fontcustom.git
|
21
|
+
|
22
|
+
RUN wget http://people.mozilla.com/~jkew/woff/woff-code-latest.zip
|
23
|
+
RUN unzip woff-code-latest.zip -d sfnt2woff && cd sfnt2woff && make && sudo mv sfnt2woff /usr/local/bin/
|
24
|
+
RUN gem install fontcustom
|
25
|
+
|
26
|
+
RUN sudo apt-get -y install nodejs-legacy npm
|
27
|
+
RUN sudo npm install -g svgo
|
@@ -0,0 +1,24 @@
|
|
1
|
+
DR_FROM base-multi
|
2
|
+
|
3
|
+
RUN sudo apt-get install -y playonlinux
|
4
|
+
|
5
|
+
RUN sudo dpkg --add-architecture i386
|
6
|
+
# RUN sudo add-apt-repository -y ppa:ubuntu-wine/ppa
|
7
|
+
# sudo apt-get install ttf-mscorefonts-installer
|
8
|
+
|
9
|
+
RUN sudo apt-get update
|
10
|
+
|
11
|
+
USER root
|
12
|
+
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
|
13
|
+
USER docker
|
14
|
+
|
15
|
+
RUN sudo apt-get install -y wine
|
16
|
+
|
17
|
+
RUN wget http://appldnld.apple.com/Safari5/041-5487.20120509.INU8B/SafariSetup.exe
|
18
|
+
|
19
|
+
ENV USER=docker
|
20
|
+
#wine SafariSetup.exe
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
DR_FROM base
|
2
|
+
|
3
|
+
RUN sudo apt-get install -y git
|
4
|
+
RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
5
|
+
|
6
|
+
USER root
|
7
|
+
|
8
|
+
RUN echo '# Rbenv' >> /etc/profile.d/rbenv.sh
|
9
|
+
RUN echo 'export RBENV_ROOT=~/.rbenv' >> /etc/profile.d/rbenv.sh
|
10
|
+
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh
|
11
|
+
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh # or /etc/profile
|
12
|
+
RUN chmod +x /etc/profile.d/rbenv.sh
|
13
|
+
RUN chown docker.docker ~/.rbenv -R
|
14
|
+
|
15
|
+
USER docker
|
16
|
+
RUN echo '. /etc/profile.d/rbenv.sh' >> ~/.bashrc
|
17
|
+
RUN echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
|
18
|
+
|
19
|
+
# RUN env
|
20
|
+
#RUN bash -l -c "rbenv rehash"
|
21
|
+
RUN rbenv rehash
|
@@ -0,0 +1,11 @@
|
|
1
|
+
DR_FROM rbenv
|
2
|
+
|
3
|
+
# Build deps
|
4
|
+
RUN sudo apt-get update
|
5
|
+
RUN sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev
|
6
|
+
# RUN sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
7
|
+
RUN sudo apt-get install -y curl
|
8
|
+
|
9
|
+
RUN git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
10
|
+
# RUN ~/.rbenv/plugins/ruby-build/install.sh
|
11
|
+
RUN rbenv install --list
|
data/images/ruby/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
dr build --version 2.3.1
|
@@ -0,0 +1,29 @@
|
|
1
|
+
DR_FROM base
|
2
|
+
|
3
|
+
|
4
|
+
RUN sudo apt-get install -y openvpn
|
5
|
+
|
6
|
+
USER root
|
7
|
+
RUN echo '#!/usr/bin/env bash' >/sbin/resolvconf && \
|
8
|
+
echo 'conf=/etc/resolv.conf' >>/sbin/resolvconf && \
|
9
|
+
echo '[[ -e $conf.orig ]] || cp -p $conf $conf.orig' >>/sbin/resolvconf && \
|
10
|
+
echo 'if [[ "${1:-""}" == "-a" ]]; then' >>/sbin/resolvconf && \
|
11
|
+
echo ' cat >${conf}' >>/sbin/resolvconf && \
|
12
|
+
echo 'elif [[ "${1:-""}" == "-d" ]]; then' >>/sbin/resolvconf && \
|
13
|
+
echo ' cat $conf.orig >$conf' >>/sbin/resolvconf && \
|
14
|
+
echo 'fi' >>/sbin/resolvconf && \
|
15
|
+
chmod +x /sbin/resolvconf
|
16
|
+
#RUN echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections
|
17
|
+
USER docker
|
18
|
+
#RUN sudo apt-get install resolvconf
|
19
|
+
|
20
|
+
RUN sudo apt-get install -y iptables
|
21
|
+
|
22
|
+
# for debuggin purpose
|
23
|
+
RUN sudo apt-get install -y dnsutils tcpdump
|
24
|
+
CMD sudo sh -c "iptables -t nat -A POSTROUTING -o tap0 -j MASQUERADE && openvpn --config config.ovpn"
|
25
|
+
|
26
|
+
# add routing on host
|
27
|
+
# ip r add 10.183.0.0/16 via 172.17.0.2 dev docker0
|
28
|
+
# TODO add dns to host
|
29
|
+
|
data/lib/drocker.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Drocker
|
4
|
+
class Image
|
5
|
+
DEFAULT_PREFIX = 'dr'
|
6
|
+
|
7
|
+
attr_reader :name, :path
|
8
|
+
|
9
|
+
def self.gid
|
10
|
+
ENV['DR_GID'] || Process.gid.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.uid
|
14
|
+
ENV['DR_UID'] || Process.uid.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.prefix
|
18
|
+
docker_prefix = ENV['DROCKER_PREFIX'] || DEFAULT_PREFIX
|
19
|
+
"#{docker_prefix}-#{uid}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.images_path
|
23
|
+
Pathname.new(ENV['DROCKER_IMAGE_PATH'] || (Pathname.new(__FILE__) + '../../../images'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(attributes = {})
|
27
|
+
@path = attributes[:path] || Pathname.pwd
|
28
|
+
@name = attributes[:name] || path.basename.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def drocker_dependant?
|
32
|
+
!parent_image_name.nil?
|
33
|
+
end
|
34
|
+
|
35
|
+
def dockerfile
|
36
|
+
path + 'Dockerfile'
|
37
|
+
end
|
38
|
+
|
39
|
+
def parent_image_name
|
40
|
+
return nil unless dockerfile.exist?
|
41
|
+
dockerfile.readlines.find do |line|
|
42
|
+
line =~ /^ *DR_FROM +(.*)/
|
43
|
+
return $1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def version
|
48
|
+
name.split(':')[1] or 'latest'
|
49
|
+
end
|
50
|
+
|
51
|
+
def parent
|
52
|
+
return nil unless parent_image_name
|
53
|
+
Image.new(path: Image.images_path + parent_image_name.split(':')[0], name: parent_image_name)
|
54
|
+
end
|
55
|
+
|
56
|
+
def docker_image_name
|
57
|
+
"#{Image.prefix}-#{name}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def env_hash
|
61
|
+
env.map {|line| line.split('=', 2) }.to_h
|
62
|
+
end
|
63
|
+
|
64
|
+
######## untested
|
65
|
+
|
66
|
+
def env
|
67
|
+
return [] unless docker_image_exist?
|
68
|
+
command = %w(docker inspect -f) + ['{{range .Config.Env }}{{println .}}{{end}}', docker_image_name]
|
69
|
+
out = Open3.capture3(*command).tap do |_, _, status|
|
70
|
+
throw "Docker command failed: #{command}" unless status.success?
|
71
|
+
end[0].split("\n")
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_s
|
75
|
+
"Image #{name} in #{path.to_s}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def docker_image_exist?
|
79
|
+
%x{docker images -q #{docker_image_name}}.length > 0
|
80
|
+
end
|
81
|
+
|
82
|
+
def tmp
|
83
|
+
path + 'tmp/dr'
|
84
|
+
end
|
85
|
+
|
86
|
+
def compile_dockerfile
|
87
|
+
return dockerfile if dockerfile.readlines.grep(/^DR_/).length == 0
|
88
|
+
|
89
|
+
tmp.mkpath
|
90
|
+
new_dockerfile = tmp + 'Dockerfile'
|
91
|
+
|
92
|
+
new_dockerfile.open('w') do |f|
|
93
|
+
dockerfile.readlines.each do |line|
|
94
|
+
case line
|
95
|
+
when /^DR_FROM +(.*)$/
|
96
|
+
f.write("FROM #{Drocker::Image.prefix}-#{$1}\n")
|
97
|
+
when /^DR_SETUID/
|
98
|
+
f.write("ENV UID #{Drocker::Image.uid}\n")
|
99
|
+
when /^DR_SETGID/
|
100
|
+
f.write("ENV GID #{Drocker::Image.gid}\n")
|
101
|
+
when /^DR_MOUNT +(.*)$/
|
102
|
+
f.write("ENV MOUNT=#{$1}\n")
|
103
|
+
else
|
104
|
+
f.write(line)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
return new_dockerfile
|
110
|
+
end
|
111
|
+
|
112
|
+
def build_command(options = {})
|
113
|
+
args = []
|
114
|
+
args.push('--force-rm') unless options[:keep]
|
115
|
+
|
116
|
+
my_dockerfile = compile_dockerfile if dockerfile.exist?
|
117
|
+
|
118
|
+
args.push('--file')
|
119
|
+
args.push(my_dockerfile.to_s)
|
120
|
+
|
121
|
+
args.push('--no-cache') if options[:no_cache]
|
122
|
+
args += ['--build-arg', "VERSION=#{version}"]
|
123
|
+
args.push('-t', docker_image_name)
|
124
|
+
|
125
|
+
%w{docker build .} + args
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Drocker
|
2
|
+
class Mount
|
3
|
+
|
4
|
+
attr_reader :from, :to
|
5
|
+
def initialize(from, to)
|
6
|
+
@from, @to = Pathname.new(from), Pathname.new(to)
|
7
|
+
end
|
8
|
+
|
9
|
+
def docker_arguments
|
10
|
+
inside = Drocker.home + to
|
11
|
+
return %W(--volume #{from.realpath.to_s}:#{inside.to_s})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: drocker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Flavio
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- flavio.pellanda@gmx.ch
|
16
|
+
executables:
|
17
|
+
- dr
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".ruby-version"
|
24
|
+
- ".travis.yml"
|
25
|
+
- Gemfile
|
26
|
+
- Guardfile
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/console
|
30
|
+
- bin/setup
|
31
|
+
- cucumber.yml
|
32
|
+
- drocker.gemspec
|
33
|
+
- exe/dr
|
34
|
+
- images/base-multi/Dockerfile
|
35
|
+
- images/base/Dockerfile
|
36
|
+
- images/desktop/Dockerfile
|
37
|
+
- images/desktop/init.sh
|
38
|
+
- images/emacs/Dockerfile
|
39
|
+
- images/fontcustom/Dockerfile
|
40
|
+
- images/office/Dockerfile
|
41
|
+
- images/playonlinux/Dockerfile
|
42
|
+
- images/rbenv/Dockerfile
|
43
|
+
- images/ruby-build/Dockerfile
|
44
|
+
- images/ruby/Dockerfile
|
45
|
+
- images/ruby/README
|
46
|
+
- images/vpn/Dockerfile
|
47
|
+
- lib/drocker.rb
|
48
|
+
- lib/drocker/image.rb
|
49
|
+
- lib/drocker/mount.rb
|
50
|
+
- lib/drocker/version.rb
|
51
|
+
homepage: https://github.com/fpellanda/drocker
|
52
|
+
licenses: []
|
53
|
+
metadata:
|
54
|
+
homepage_uri: https://github.com/fpellanda/drocker
|
55
|
+
source_code_uri: https://github.com/fpellanda/drocker
|
56
|
+
changelog_uri: https://github.com/fpellanda/drockerCHANGELOG.md
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.3.0
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubygems_version: 3.1.2
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: Include features into Dockerfiles
|
76
|
+
test_files: []
|