spectat-jekyll 0.1.3 → 0.2.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 +4 -4
- data/.rubocop.yml +3 -1
- data/lib/spectat/jekyll/rake_task.rb +81 -0
- data/lib/spectat/jekyll/rake_task/Capfile.erb +1 -0
- data/lib/spectat/jekyll/rake_task/Dockerfile.builder.erb +66 -0
- data/lib/spectat/jekyll/rake_task/Dockerfile.built.erb +3 -0
- data/lib/spectat/jekyll/rake_task/Dockerfile.deploy.erb +25 -0
- data/lib/spectat/jekyll/rake_task/config-deploy.rb.erb +2 -0
- data/lib/spectat/jekyll/rake_task/gitlab-ci.yml.erb +199 -0
- data/lib/spectat/jekyll/rake_task/helper.rb +97 -0
- data/lib/spectat/jekyll/version.rb +1 -1
- data/spectat-jekyll.gemspec +1 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d17d33184e64289cb44daf898961cee419b6378866a8eaa7048946be871bcc90
|
4
|
+
data.tar.gz: 0aceb197a656bf9289cff04320bc8cc15c076fbd8a184761674f987bda04922a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88546ecefe943d90318caeaa7ed72df112eadf7a580846088bec4ba704d446b6cf4bd025f0582f27a2aa47affdccd0cff04a373e88f0594f843efb2e14f1fe15
|
7
|
+
data.tar.gz: e5c5c2559317d856c6e7ae24a4875fb65d9ba522cc4fcf2d9718c2b5057ba9d89013b02995b893fc980b500387fb92fa4469fc51dcb4dc3e9589cd8a431db5e5
|
data/.rubocop.yml
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spectat/jekyll/rake_task/helper'
|
2
|
+
|
3
|
+
namespace :docker do
|
4
|
+
desc 'Build site\'s image'
|
5
|
+
task :build, [:full_repo_path, :image_type, :image_tag] do |_, args|
|
6
|
+
helper = Spectat::Jekyll::RakeTask::DockerHelper.new(args[:full_repo_path], args[:image_type].to_sym, args[:image_tag])
|
7
|
+
sh helper.docker_build_command
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :gitlab do
|
12
|
+
desc 'Generate the .gitlab-ci.yml file to a given `filename`'
|
13
|
+
task :generate_path, [:filename, :full_repo_path, :fqdn] do |_, args|
|
14
|
+
helper = Spectat::Jekyll::RakeTask::GitLabHelper.new(args[:full_repo_path], args[:fqdn])
|
15
|
+
File.write(args[:filename], helper.render_template)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate the .gitlab-ci.yml file'
|
19
|
+
task :generate, [:full_repo_path, :fqdn] do |_, args|
|
20
|
+
Rake::Task['gitlab:generate_path'].invoke('.gitlab-ci.yml', args[:full_repo_path], args[:fqdn])
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Validate whether .gitlab-ci.yml has been updated'
|
24
|
+
task :validate, [:full_repo_path, :fqdn] do |_, args|
|
25
|
+
Rake::Task['gitlab:generate_path'].invoke('.gitlab-ci.new.yml', args[:full_repo_path], args[:fqdn])
|
26
|
+
sh 'diff -au .gitlab-ci.yml .gitlab-ci.new.yml'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
namespace :capistrano do # rubocop:disable Metrics/BlockLength
|
31
|
+
namespace :capfile do
|
32
|
+
desc 'Generate the Capfile file to a given `filename`'
|
33
|
+
task :generate_path, [:filename, :full_repo_path, :fqdn] do |_, args|
|
34
|
+
helper = Spectat::Jekyll::RakeTask::CapistranoHelper.new(args[:full_repo_path], args[:fqdn])
|
35
|
+
File.write(args[:filename], helper.render_capfile)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Generate the Capfile file'
|
39
|
+
task :generate, [:full_repo_path, :fqdn] do |_, args|
|
40
|
+
Rake::Task['capistrano:capfile:generate_path'].invoke('Capfile', args[:full_repo_path], args[:fqdn])
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Validate whether Capfile has been updated'
|
44
|
+
task :validate, [:full_repo_path, :fqdn] do |_, args|
|
45
|
+
Rake::Task['capistrano:capfile:generate_path'].invoke('Capfile.new', args[:full_repo_path], args[:fqdn])
|
46
|
+
sh 'diff -au Capfile Capfile.new'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
namespace :deployrb do
|
51
|
+
desc 'Generate the config/deploy.rb file to a given `filename`'
|
52
|
+
task :generate_path, [:filename, :full_repo_path, :fqdn] do |_, args|
|
53
|
+
FileUtils.mkdir_p(File.dirname(args[:filename]))
|
54
|
+
helper = Spectat::Jekyll::RakeTask::CapistranoHelper.new(args[:full_repo_path], args[:fqdn])
|
55
|
+
File.write(args[:filename], helper.render_deployrb)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'Generate the config/deploy.rb file'
|
59
|
+
task :generate, [:full_repo_path, :fqdn] do |_, args|
|
60
|
+
Rake::Task['capistrano:deployrb:generate_path'].invoke('config/deploy.rb', args[:full_repo_path], args[:fqdn])
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'Validate whether config/deploy.rb has been updated'
|
64
|
+
task :validate, [:full_repo_path, :fqdn] do |_, args|
|
65
|
+
Rake::Task['capistrano:deployrb:generate_path'].invoke('config/deploy.rb.new', args[:full_repo_path], args[:fqdn])
|
66
|
+
sh 'diff -au config/deploy.rb config/deploy.rb.new'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
desc 'Generate Capfile and config/deploy.rb files'
|
71
|
+
task :generate, [:full_repo_path, :fqdn] do |_, args|
|
72
|
+
Rake::Task['capistrano:capfile:generate'].invoke(args[:full_repo_path], args[:fqdn])
|
73
|
+
Rake::Task['capistrano:deployrb:generate'].invoke(args[:full_repo_path], args[:fqdn])
|
74
|
+
end
|
75
|
+
|
76
|
+
desc 'Validate Capfile and config/deploy.rb are up-to-date'
|
77
|
+
task :generate, [:full_repo_path, :fqdn] do |_, args|
|
78
|
+
Rake::Task['capistrano:capfile:validate'].invoke(args[:full_repo_path], args[:fqdn])
|
79
|
+
Rake::Task['capistrano:deployrb:validate'].invoke(args[:full_repo_path], args[:fqdn])
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'spectat/jekyll/deploy'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
FROM alpine:latest
|
2
|
+
MAINTAINER Jamie Tanna <docker@jamietanna.co.uk>
|
3
|
+
|
4
|
+
# Install NodeJS and Ruby {{{
|
5
|
+
WORKDIR "/opt/node"
|
6
|
+
|
7
|
+
ENV PATH=$PATH:/opt/node/bin
|
8
|
+
|
9
|
+
RUN apk update && \
|
10
|
+
apk upgrade && \
|
11
|
+
# Required to set timezone {{{
|
12
|
+
apk add tzdata && \
|
13
|
+
# }}}
|
14
|
+
# NodeJS {{{
|
15
|
+
apk add nodejs \
|
16
|
+
# gifsicle jpegtran-bin
|
17
|
+
autoconf automake file nasm && \
|
18
|
+
# }}}
|
19
|
+
# Ruby {{{
|
20
|
+
apk add ruby-dev ruby-bundler && \
|
21
|
+
apk add git \
|
22
|
+
build-base \
|
23
|
+
# for the FFI gem: https://github.com/ffi/ffi/issues/485#issuecomment-191159190
|
24
|
+
libffi-dev \
|
25
|
+
# for the nokogiri gem: https://github.com/gliderlabs/docker-alpine/issues/53#issuecomment-173412882
|
26
|
+
libxml2-dev libxslt-dev
|
27
|
+
# }}}
|
28
|
+
# }}}
|
29
|
+
|
30
|
+
# Ensure timezone is set correctly {{{
|
31
|
+
RUN cp /usr/share/zoneinfo/Europe/London /etc/localtime
|
32
|
+
RUN echo 'Europe/London' > /etc/timezone
|
33
|
+
# }}}
|
34
|
+
|
35
|
+
# Install package dependencies {{{
|
36
|
+
RUN mkdir -p /app/site/_site /app/vendor/git
|
37
|
+
WORKDIR "/app"
|
38
|
+
|
39
|
+
# https://github.com/docker-library/ruby/issues/45
|
40
|
+
ENV LANG C.UTF-8
|
41
|
+
|
42
|
+
# Set /app as the initial directory for the dependencies, allowing the site to
|
43
|
+
# then be mounted into /app/site, so we don't override any of our
|
44
|
+
# pre-downloaded NPM dependencies {{{
|
45
|
+
# Ensure we have the latest Node dependencies, which should be changed less
|
46
|
+
# often than the Ruby dependencies (ie Jekyll, Capistrano) so will want to be
|
47
|
+
# cached longer {{{
|
48
|
+
COPY package.json /app/
|
49
|
+
RUN npm install
|
50
|
+
ENV PATH=$PATH:/app/node_modules/.bin
|
51
|
+
# }}}
|
52
|
+
# Ensure we have the latest Ruby dependencies {{{
|
53
|
+
COPY Gemfile Gemfile.lock /app/
|
54
|
+
COPY vendor/git/ /app/vendor/git/
|
55
|
+
# Don't pull in deploy dependencies as they're a separate Docker image
|
56
|
+
ENV BUNDLE_WITHOUT=deploy
|
57
|
+
RUN bundle install
|
58
|
+
# }}}
|
59
|
+
# }}}
|
60
|
+
|
61
|
+
# Once set up, use our mounted directory for the site
|
62
|
+
WORKDIR "/app/site"
|
63
|
+
|
64
|
+
# Default action is to serve the site {{{
|
65
|
+
CMD ["gulp", "serve"]
|
66
|
+
# }}}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
FROM alpine:latest
|
2
|
+
MAINTAINER Jamie Tanna <docker@jamietanna.co.uk>
|
3
|
+
|
4
|
+
WORKDIR "/site"
|
5
|
+
|
6
|
+
RUN apk update && \
|
7
|
+
apk upgrade && \
|
8
|
+
apk add ruby-dev ruby-bundler && \
|
9
|
+
apk add git \
|
10
|
+
build-base \
|
11
|
+
openssh-client
|
12
|
+
|
13
|
+
ADD Gemfile /site
|
14
|
+
ADD Gemfile.lock /site
|
15
|
+
|
16
|
+
RUN bundle install --without build test
|
17
|
+
|
18
|
+
# Bake Capistrano config into image {{{
|
19
|
+
# build the base file structure so we can copy into the correct directories
|
20
|
+
RUN mkdir -p /site/config /site/lib/capistrano
|
21
|
+
|
22
|
+
ADD Capfile /site
|
23
|
+
|
24
|
+
ADD config/deploy.rb /site/config
|
25
|
+
# }}}
|
@@ -0,0 +1,199 @@
|
|
1
|
+
variables:
|
2
|
+
CONTAINER_IMAGE_BASE_URL: registry.gitlab.com/<%= @full_repo_path %>
|
3
|
+
CONTAINER_BUILT_IMAGE: $CONTAINER_IMAGE_BASE_URL:$CI_COMMIT_REF_SLUG
|
4
|
+
CONTAINER_BUILDER_IMAGE: $CONTAINER_IMAGE_BASE_URL/builder:$CI_COMMIT_REF_SLUG
|
5
|
+
CONTAINER_DEPLOY_IMAGE: $CONTAINER_IMAGE_BASE_URL/deploy:$CI_COMMIT_REF_SLUG
|
6
|
+
RELEASE_CONTAINER_BUILT_IMAGE: $CONTAINER_IMAGE_BASE_URL:latest
|
7
|
+
RELEASE_CONTAINER_BUILDER_IMAGE: $CONTAINER_IMAGE_BASE_URL/builder:latest
|
8
|
+
RELEASE_CONTAINER_DEPLOY_IMAGE: $CONTAINER_IMAGE_BASE_URL/deploy:latest
|
9
|
+
DOCKER_DRIVER: overlay
|
10
|
+
URL_PRODUCTION: https://<%= @fqdn_production %>
|
11
|
+
URL_STAGING: https://<%= @fqdn_staging %>
|
12
|
+
URL_REVIEW_SUFFIX: <%= @fqdn_suffix_review %>
|
13
|
+
|
14
|
+
stages:
|
15
|
+
- build
|
16
|
+
- test
|
17
|
+
- review
|
18
|
+
- staging
|
19
|
+
- release
|
20
|
+
- production
|
21
|
+
|
22
|
+
# Ensure that the site builds {{{
|
23
|
+
build_image:
|
24
|
+
image: docker:1.13
|
25
|
+
services:
|
26
|
+
- docker:1.13-dind
|
27
|
+
stage: build
|
28
|
+
script:
|
29
|
+
# Grab the private submodules (public are fine) {{{
|
30
|
+
- apk --update add openssh-client git
|
31
|
+
- .ci/ssh-init.sh
|
32
|
+
- eval $(ssh-agent -s) && echo "$RO_CLONE_PRIVATE_KEY" | ssh-add -
|
33
|
+
- git submodule update --init
|
34
|
+
# }}}
|
35
|
+
|
36
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
37
|
+
# pull the latest base image on a master build
|
38
|
+
- docker pull $CONTAINER_BUILDER_IMAGE || docker pull $RELEASE_CONTAINER_BUILDER_IMAGE || true
|
39
|
+
# Build the builder image {{{
|
40
|
+
- bundle exec rake "docker:build[<%= @full_repo_path %>,builder,$CI_COMMIT_REF_SLUG]"
|
41
|
+
- docker push $CONTAINER_BUILDER_IMAGE
|
42
|
+
# }}}
|
43
|
+
# Build the built image {{{
|
44
|
+
- docker run -v $(readlink -f .):/app/site $CONTAINER_BUILDER_IMAGE gulp build --production
|
45
|
+
- bundle exec rake "docker:build[<%= @full_repo_path %>,built,$CI_COMMIT_REF_SLUG]"
|
46
|
+
- docker push $CONTAINER_BUILT_IMAGE
|
47
|
+
# }}}
|
48
|
+
# Build the deploy image {{{
|
49
|
+
- docker pull $CONTAINER_DEPLOY_IMAGE || docker pull $RELEASE_CONTAINER_DEPLOY_IMAGE || true
|
50
|
+
- bundle exec rake "docker:build[<%= @full_repo_path %>,deploy,$CI_COMMIT_REF_SLUG]"
|
51
|
+
- docker push $CONTAINER_DEPLOY_IMAGE
|
52
|
+
# }}}
|
53
|
+
# }}}
|
54
|
+
|
55
|
+
test:
|
56
|
+
image: $CONTAINER_BUILDER_IMAGE
|
57
|
+
stage: test
|
58
|
+
script:
|
59
|
+
- bundle exec rake 'capistrano:validate[<%= @full_repo_path %>,<%= @fqdn_production %>]'
|
60
|
+
- bundle exec rake 'gitlab:validate[<%= @full_repo_path %>,<%= @fqdn_production %>]'
|
61
|
+
|
62
|
+
# Review Apps {{{
|
63
|
+
review_deploy:
|
64
|
+
image: $CONTAINER_DEPLOY_IMAGE
|
65
|
+
stage: review
|
66
|
+
script:
|
67
|
+
# ensure we're in the directory with our capistrano configuration
|
68
|
+
- cd /site
|
69
|
+
# ensure that deployments can use the SSH key that is passed in via the
|
70
|
+
# environment variables. Via https://docs.gitlab.com/ce/ci/ssh_keys/README.html
|
71
|
+
- eval $(ssh-agent -s)
|
72
|
+
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
|
73
|
+
- echo -e "$REVIEW_SSH_PRIVATE_KEY" | ssh-add -
|
74
|
+
- cap review deploy
|
75
|
+
environment:
|
76
|
+
name: review/$CI_COMMIT_REF_SLUG
|
77
|
+
url: https://$CI_COMMIT_REF_SLUG.$URL_REVIEW_SUFFIX
|
78
|
+
on_stop: review_stop
|
79
|
+
only:
|
80
|
+
- branches
|
81
|
+
variables:
|
82
|
+
GIT_STRATEGY: none
|
83
|
+
except:
|
84
|
+
- master
|
85
|
+
|
86
|
+
review_stop:
|
87
|
+
image: $CONTAINER_DEPLOY_IMAGE
|
88
|
+
stage: review
|
89
|
+
script:
|
90
|
+
# ensure we're in the directory with our capistrano configuration
|
91
|
+
- cd /site
|
92
|
+
# ensure that deployments can use the SSH key that is passed in via the
|
93
|
+
# environment variables. Via https://docs.gitlab.com/ce/ci/ssh_keys/README.html
|
94
|
+
- eval $(ssh-agent -s)
|
95
|
+
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
|
96
|
+
- echo -e "$REVIEW_SSH_PRIVATE_KEY" | ssh-add -
|
97
|
+
- cap review stop
|
98
|
+
environment:
|
99
|
+
name: review/$CI_COMMIT_REF_SLUG
|
100
|
+
action: stop
|
101
|
+
variables:
|
102
|
+
GIT_STRATEGY: none
|
103
|
+
when: manual
|
104
|
+
only:
|
105
|
+
- branches
|
106
|
+
except:
|
107
|
+
- master
|
108
|
+
# }}}
|
109
|
+
|
110
|
+
# Staging {{{
|
111
|
+
staging_deploy:
|
112
|
+
image: $CONTAINER_DEPLOY_IMAGE
|
113
|
+
stage: staging
|
114
|
+
script:
|
115
|
+
# ensure we're in the directory with our capistrano configuration
|
116
|
+
- cd /site
|
117
|
+
# ensure that deployments can use the SSH key that is passed in via the
|
118
|
+
# environment variables. Via https://docs.gitlab.com/ce/ci/ssh_keys/README.html
|
119
|
+
- eval $(ssh-agent -s)
|
120
|
+
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
|
121
|
+
- echo -e "$STAGING_SSH_PRIVATE_KEY" | ssh-add -
|
122
|
+
- cap staging deploy
|
123
|
+
environment:
|
124
|
+
name: staging
|
125
|
+
url: $URL_STAGING
|
126
|
+
variables:
|
127
|
+
GIT_STRATEGY: none
|
128
|
+
only:
|
129
|
+
- master
|
130
|
+
# }}}
|
131
|
+
|
132
|
+
# Push the images up to the registry as our :latest image, on master {{{
|
133
|
+
release_builder_image:
|
134
|
+
image: docker:1.13
|
135
|
+
services:
|
136
|
+
- docker:1.13-dind
|
137
|
+
stage: release
|
138
|
+
script:
|
139
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
140
|
+
- docker pull "$CONTAINER_BUILDER_IMAGE"
|
141
|
+
- docker tag "$CONTAINER_BUILDER_IMAGE" "$RELEASE_CONTAINER_BUILDER_IMAGE"
|
142
|
+
- docker push "$RELEASE_CONTAINER_BUILDER_IMAGE"
|
143
|
+
variables:
|
144
|
+
GIT_STRATEGY: none
|
145
|
+
only:
|
146
|
+
- master
|
147
|
+
|
148
|
+
release_built_image:
|
149
|
+
image: docker:1.13
|
150
|
+
services:
|
151
|
+
- docker:1.13-dind
|
152
|
+
stage: release
|
153
|
+
script:
|
154
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
155
|
+
- docker pull "$CONTAINER_BUILT_IMAGE"
|
156
|
+
- docker tag "$CONTAINER_BUILT_IMAGE" "$RELEASE_CONTAINER_BUILT_IMAGE"
|
157
|
+
- docker push "$RELEASE_CONTAINER_BUILT_IMAGE"
|
158
|
+
variables:
|
159
|
+
GIT_STRATEGY: none
|
160
|
+
only:
|
161
|
+
- master
|
162
|
+
|
163
|
+
release_deploy_image:
|
164
|
+
image: docker:1.13
|
165
|
+
services:
|
166
|
+
- docker:1.13-dind
|
167
|
+
stage: release
|
168
|
+
script:
|
169
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
170
|
+
- docker pull "$CONTAINER_DEPLOY_IMAGE"
|
171
|
+
- docker tag "$CONTAINER_DEPLOY_IMAGE" "$RELEASE_CONTAINER_DEPLOY_IMAGE"
|
172
|
+
- docker push "$RELEASE_CONTAINER_DEPLOY_IMAGE"
|
173
|
+
variables:
|
174
|
+
GIT_STRATEGY: none
|
175
|
+
only:
|
176
|
+
- master
|
177
|
+
# }}}
|
178
|
+
|
179
|
+
# Production {{{
|
180
|
+
prod_deploy:
|
181
|
+
image: $CONTAINER_DEPLOY_IMAGE
|
182
|
+
stage: production
|
183
|
+
script:
|
184
|
+
# ensure we're in the directory with our capistrano configuration
|
185
|
+
- cd /site
|
186
|
+
# ensure that deployments can use the SSH key that is passed in via the
|
187
|
+
# environment variables. Via https://docs.gitlab.com/ce/ci/ssh_keys/README.html
|
188
|
+
- eval $(ssh-agent -s)
|
189
|
+
# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
|
190
|
+
- echo -e "$PRODUCTION_SSH_PRIVATE_KEY" | ssh-add -
|
191
|
+
- cap production deploy
|
192
|
+
environment:
|
193
|
+
name: production
|
194
|
+
url: $URL_PRODUCTION
|
195
|
+
variables:
|
196
|
+
GIT_STRATEGY: none
|
197
|
+
only:
|
198
|
+
- master
|
199
|
+
# }}}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'erubis'
|
2
|
+
require 'spectat/fqdn'
|
3
|
+
|
4
|
+
module Spectat
|
5
|
+
module Jekyll
|
6
|
+
module RakeTask
|
7
|
+
# Helper class for standardising Docker configuration
|
8
|
+
class DockerHelper
|
9
|
+
attr_reader :full_repo_path
|
10
|
+
attr_reader :image_type
|
11
|
+
attr_reader :image_tag
|
12
|
+
|
13
|
+
VALID_IMAGE_TYPES = %i[builder built deploy].freeze
|
14
|
+
|
15
|
+
def initialize(full_repo_path, image_type, image_tag)
|
16
|
+
raise ArgumentError, 'image_type must be ' + VALID_IMAGE_TYPES.to_s unless VALID_IMAGE_TYPES.include?(image_type)
|
17
|
+
|
18
|
+
@full_repo_path = full_repo_path
|
19
|
+
@image_type = image_type
|
20
|
+
@image_tag = image_tag
|
21
|
+
@image_name = case @image_type
|
22
|
+
when :built
|
23
|
+
''
|
24
|
+
else
|
25
|
+
"/#{@image_type}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def image_path
|
30
|
+
"registry.gitlab.com/#{@full_repo_path}#{@image_name}:#{@image_tag}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def docker_build_command
|
34
|
+
"docker build --pull --cache-from #{image_path} --tag #{image_path} --file #{path_to_dockerfile(__FILE__)} ."
|
35
|
+
end
|
36
|
+
|
37
|
+
def path_to_dockerfile(executing_script_path)
|
38
|
+
dockerfile = "Dockerfile.#{@image_type}.erb"
|
39
|
+
full_path = File.join(File.dirname(executing_script_path), dockerfile)
|
40
|
+
raise IOError, "#{full_path} doesn't exist" unless File.file?(full_path)
|
41
|
+
full_path
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Helper class for generating standardised GitLab CI configuration
|
46
|
+
class GitLabHelper
|
47
|
+
attr_reader :fqdn
|
48
|
+
attr_reader :full_repo_path
|
49
|
+
|
50
|
+
def initialize(full_repo_path, fqdn)
|
51
|
+
@full_repo_path = full_repo_path
|
52
|
+
@fqdn = fqdn
|
53
|
+
end
|
54
|
+
|
55
|
+
def render_template
|
56
|
+
template = File.read(File.join(File.dirname(__FILE__), 'gitlab-ci.yml.erb'))
|
57
|
+
erb = Erubis::Eruby.new(template)
|
58
|
+
|
59
|
+
staging_helper = Spectat::Fqdn.new(@fqdn, 'staging')
|
60
|
+
review_helper = Spectat::Fqdn.new(staging_helper.review_apps_fqdn, 'staging')
|
61
|
+
|
62
|
+
erb.evaluate(
|
63
|
+
fqdn_production: Spectat::Fqdn.new(@fqdn, 'production').fqdn,
|
64
|
+
fqdn_staging: staging_helper.fqdn,
|
65
|
+
fqdn_suffix_review: review_helper.fqdn,
|
66
|
+
full_repo_path: @full_repo_path
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Helper class for generating standardised Capistrano configuration
|
72
|
+
class CapistranoHelper
|
73
|
+
attr_reader :fqdn
|
74
|
+
attr_reader :full_repo_path
|
75
|
+
|
76
|
+
def initialize(full_repo_path, fqdn)
|
77
|
+
@full_repo_path = full_repo_path
|
78
|
+
@fqdn = fqdn
|
79
|
+
end
|
80
|
+
|
81
|
+
def render_capfile
|
82
|
+
File.read(File.join(File.dirname(__FILE__), 'Capfile.erb'))
|
83
|
+
end
|
84
|
+
|
85
|
+
def render_deployrb
|
86
|
+
template = File.read(File.join(File.dirname(__FILE__), 'config-deploy.rb.erb'))
|
87
|
+
erb = Erubis::Eruby.new(template)
|
88
|
+
|
89
|
+
erb.evaluate(
|
90
|
+
fqdn: @fqdn,
|
91
|
+
full_repo_path: @full_repo_path
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/spectat-jekyll.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'rubocop', '~> 0.55.0'
|
36
36
|
|
37
37
|
spec.add_runtime_dependency 'capistrano', '~> 3.7.1'
|
38
|
+
spec.add_runtime_dependency 'erubis'
|
38
39
|
spec.add_runtime_dependency 'jekyll', '~> 3.7.3'
|
39
40
|
# https://github.com/jekyll/jekyll/issues/4838
|
40
41
|
spec.add_runtime_dependency 'json'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectat-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Tanna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.7.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: erubis
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: jekyll
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +159,14 @@ files:
|
|
145
159
|
- lib/spectat/jekyll/deploy/stages/staging.rb
|
146
160
|
- lib/spectat/jekyll/deploy/tasks/deploy.rake
|
147
161
|
- lib/spectat/jekyll/deploy/tasks/review.rake
|
162
|
+
- lib/spectat/jekyll/rake_task.rb
|
163
|
+
- lib/spectat/jekyll/rake_task/Capfile.erb
|
164
|
+
- lib/spectat/jekyll/rake_task/Dockerfile.builder.erb
|
165
|
+
- lib/spectat/jekyll/rake_task/Dockerfile.built.erb
|
166
|
+
- lib/spectat/jekyll/rake_task/Dockerfile.deploy.erb
|
167
|
+
- lib/spectat/jekyll/rake_task/config-deploy.rb.erb
|
168
|
+
- lib/spectat/jekyll/rake_task/gitlab-ci.yml.erb
|
169
|
+
- lib/spectat/jekyll/rake_task/helper.rb
|
148
170
|
- lib/spectat/jekyll/version.rb
|
149
171
|
- spectat-jekyll.gemspec
|
150
172
|
homepage: https://gitlab.com/spectat/gems/spectat-jekyll-gem
|