chbuild 0.0.2

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.
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ module CHBuild
3
+ # Utils class
4
+ class Utils
5
+ def self.generate_conatiner_name(prefix: nil, job_name: nil, build_id: nil)
6
+ prefix ||= ENV['CONTAINER_PREFIX']
7
+ prefix = "#{prefix}-" unless prefix.nil? || prefix.empty?
8
+
9
+ job_name ||= ENV['JOB_NAME'] || random_string
10
+ build_id ||= ENV['BUILD_ID'] || "r#{Random.rand(1000)}"
11
+
12
+ "#{prefix}#{job_name}-#{build_id}"
13
+ end
14
+
15
+ def self.virtual_hostname(prefix: nil, job_name: nil, branch_name: nil)
16
+ prefix ||= ENV['HOST_PREFIX']
17
+ prefix = "#{prefix}." unless prefix.nil? || prefix.empty?
18
+
19
+ job_name ||= ENV['JOB_NAME'] || random_string.downcase
20
+ branch_name ||= (ENV['BRANCH_NAME'] || 'master').gsub(%r{.*/}, '')
21
+
22
+ "#{prefix}#{branch_name}.#{job_name}"
23
+ end
24
+
25
+ def self.fqdn(prefix: nil, job_name: nil, branch_name: nil)
26
+ vhost = virtual_hostname(
27
+ prefix: prefix,
28
+ job_name: job_name,
29
+ branch_name: branch_name
30
+ )
31
+
32
+ main_domain = ENV['DOMAIN'] || CHBuild::DEFAULT_DOMAIN
33
+
34
+ "#{vhost}.#{main_domain}"
35
+ end
36
+
37
+ def self.random_string(length: 8)
38
+ o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
39
+ (0...length).map { o[rand(o.length)] }.join
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module CHBuild
3
+ VERSION = '0.0.2'
4
+ end
@@ -0,0 +1,104 @@
1
+ FROM alpine:3.3
2
+
3
+ MAINTAINER 'Cheppers Ltd. <info@cheppers.com> (github:Cheppers)'
4
+
5
+ ENV REFRESHED_AT <%= refreshed_at_date %>
6
+
7
+ # PHP Configuration
8
+ ENV TIMEZONE <%= php_timezone %>
9
+ ENV PHP_MEMORY_LIMIT <%= php_memory_limit %>
10
+ ENV MAX_UPLOAD <%= max_upload %>
11
+ ENV PHP_MAX_FILE_UPLOAD <%= php_max_file_upload %>
12
+ ENV PHP_MAX_POST <%= php_max_post %>
13
+ ENV TERM dumb # for mysql-client
14
+
15
+ # Install packages
16
+ RUN apk add --no-cache \
17
+ bash \
18
+ apache2-proxy apache2-utils \
19
+ mysql-client \
20
+ tzdata \
21
+ php-mcrypt \
22
+ php-soap \
23
+ php-openssl \
24
+ php-gmp \
25
+ php-pdo_odbc \
26
+ php-json \
27
+ php-dom \
28
+ php-pdo \
29
+ php-zip \
30
+ php-mysql \
31
+ php-sqlite3 \
32
+ php-apcu \
33
+ php-pdo_pgsql \
34
+ php-bcmath \
35
+ php-gd \
36
+ php-xcache \
37
+ php-odbc \
38
+ php-pdo_mysql \
39
+ php-pdo_sqlite \
40
+ php-gettext \
41
+ php-xmlreader \
42
+ php-xmlrpc \
43
+ php-bz2 \
44
+ php-memcache \
45
+ php-mssql \
46
+ php-iconv \
47
+ php-pdo_dblib \
48
+ php-curl \
49
+ php-ctype \
50
+ php-phar \
51
+ php-fpm
52
+
53
+ # Configure apache proxy (apache because of `.ht` files)
54
+ RUN echo \
55
+ 'ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/www/$1' >> /etc/apache2/httpd.conf && \
56
+ echo 'DirectoryIndex /index.php' >> /etc/apache2/httpd.conf && \
57
+ sed -ie 's/#ServerName .*/ServerName localhost/i' /etc/apache2/httpd.conf && \
58
+ sed -ie 's/#LoadModule slotmem_shm_module/LoadModule slotmem_shm_module/' \
59
+ /etc/apache2/httpd.conf && \
60
+ sed -ie 's#/var/www/localhost/htdocs#/www#g' /etc/apache2/httpd.conf && \
61
+ sed -ie 's#LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so##g' /etc/apache2/conf.d/proxy.conf && \
62
+ mkdir /run/apache2/
63
+
64
+ # Configure Timezone, important for php
65
+ RUN cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
66
+ echo "${TIMEZONE}" > /etc/timezone
67
+
68
+ # Configure PHP-FPM
69
+ RUN sed -i "s|;*daemonize\s*=\s*yes|daemonize = no|g" /etc/php/php-fpm.conf && \
70
+ sed -ie 's#^listen\s*=\s*.*#listen = 9000#g' \
71
+ /etc/php/php-fpm.conf && \
72
+ sed -i "s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i" \
73
+ /etc/php/php.ini && \
74
+ sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" \
75
+ /etc/php/php.ini && \
76
+ sed -i "s|;*upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|i" \
77
+ /etc/php/php.ini && \
78
+ sed -i "s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i" \
79
+ /etc/php/php.ini && \
80
+ sed -i "s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i" \
81
+ /etc/php/php.ini && \
82
+ sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= 0|i" /etc/php/php.ini
83
+
84
+ # Install Composer
85
+ RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
86
+ php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
87
+ php composer-setup.php --install-dir /usr/bin --filename=composer composer && \
88
+ php -r "unlink('composer-setup.php');" && \
89
+ chmod +x /usr/bin/composer
90
+
91
+ # Install Drush
92
+ RUN php -r "readfile('http://files.drush.org/drush.phar');" > /usr/local/bin/drush && \
93
+ php /usr/local/bin/drush core-status && \
94
+ chmod +x /usr/local/bin/drush
95
+
96
+ # Codebase
97
+ RUN mkdir /www
98
+ VOLUME ["/www"]
99
+
100
+ RUN mkdir /initscripts
101
+
102
+ WORKDIR /www
103
+
104
+ EXPOSE 80
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ # ========== GENERATED SCRIPT ==========
4
+ <%= before_script %>
5
+ # ========== GENERATED SCRIPT ==========
6
+
7
+ echo "Run InitScripts"
8
+ find /initscripts -type f -print -exec {} \;
9
+
10
+ echo "Start Apache2"
11
+ /usr/sbin/httpd -d . -f /etc/apache2/httpd.conf
12
+
13
+ if [ ! -f /www/index.php ]; then
14
+ echo "Populate '/www' because it's empty"
15
+ echo '<?php phpinfo(); ?>' > /www/index.php
16
+ fi
17
+
18
+ echo "Start PHP-FPM"
19
+ /usr/bin/php-fpm
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chbuild
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Cheppers Ltd.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: excon
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.46'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0.46'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.46'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0.46'
47
+ - !ruby/object:Gem::Dependency
48
+ name: docker-api
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.31'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '1.31'
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.31'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '1.31'
67
+ - !ruby/object:Gem::Dependency
68
+ name: thor
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.19'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.19'
81
+ - !ruby/object:Gem::Dependency
82
+ name: bundler
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.12'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.12'
95
+ - !ruby/object:Gem::Dependency
96
+ name: pry
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0.10'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0.10'
109
+ - !ruby/object:Gem::Dependency
110
+ name: rake
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '10.0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '10.0'
123
+ - !ruby/object:Gem::Dependency
124
+ name: rubocop
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.40'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '0.40'
137
+ - !ruby/object:Gem::Dependency
138
+ name: rspec
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: '3.0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - "~>"
149
+ - !ruby/object:Gem::Version
150
+ version: '3.0'
151
+ description: |2
152
+ chbuild is an open-source command line application written in Ruby.
153
+ It's main purpose is to simplify web app development by running a site
154
+ using Docker containers so you don't have to install Apache, PHP and
155
+ PHP extensions on your own machine.
156
+ email: info@cheppers.com
157
+ executables:
158
+ - chbuild
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - ".editorconfig"
163
+ - ".gitignore"
164
+ - ".rspec"
165
+ - ".rubocop.yml"
166
+ - ".travis.yml"
167
+ - CHANGELOG.md
168
+ - CODE_OF_CONDUCT.md
169
+ - Gemfile
170
+ - LICENSE.txt
171
+ - README.md
172
+ - Rakefile
173
+ - bin/chbuild
174
+ - bin/console
175
+ - bin/setup
176
+ - chbuild.gemspec
177
+ - lib/chbuild.rb
178
+ - lib/chbuild/bindable_hash.rb
179
+ - lib/chbuild/config.rb
180
+ - lib/chbuild/config/before.rb
181
+ - lib/chbuild/config/env.rb
182
+ - lib/chbuild/config/errors.rb
183
+ - lib/chbuild/config/use.rb
184
+ - lib/chbuild/config/version.rb
185
+ - lib/chbuild/constants.rb
186
+ - lib/chbuild/controller.rb
187
+ - lib/chbuild/utils.rb
188
+ - lib/chbuild/version.rb
189
+ - templates/base-docker-container.erb
190
+ - templates/init.sh.erb
191
+ homepage: https://github.com/Cheppers/chbuild
192
+ licenses:
193
+ - MIT
194
+ metadata:
195
+ allowed_push_host: https://rubygems.org
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: 2.3.0
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubyforge_project:
212
+ rubygems_version: 2.5.1
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: Cheppers Build Tool
216
+ test_files: []