Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker improvements #485

Merged
merged 5 commits into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ DEPENDENCIES
yard (= 0.9.16)

BUNDLED WITH
1.16.3
1.16.4
28 changes: 22 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace :lint do

require "rubocop/rake_task"

desc "Checks ruby code style with RuboCop"
RuboCop::RakeTask.new

desc "Checks markdown code style with Markdownlint"
Expand All @@ -95,20 +96,35 @@ task lint: "lint:all"
namespace :docker do
require_relative "docker/manager"

desc "Build docker images"
task :build do
desc "Build all docker images"
task :build_all do
Docker::Manager.build_all
end

desc "Test docker images"
task :test do
desc "Build the default docker image"
task :build do
Docker::Manager.build_default
end

desc "Test all docker images"
task :test_all do
Docker::Manager.test_all
end

desc "Push docker images to dockerhub"
task :push do
desc "Test the default docker image"
task :test do
Docker::Manager.test_default
end

desc "Push all docker images to dockerhub"
task :push_all do
Docker::Manager.push_all
end

desc "Push the default docker image to dockerhub"
task :push do
Docker::Manager.push_default
end
end

task default: %i[compile test lint]
Expand Down
2 changes: 2 additions & 0 deletions bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ m = Module.new do
end

def lockfile_version
return unless File.file?(lockfile)

lockfile_contents = File.read(lockfile)

regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Expand Down
13 changes: 12 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ RUN set -ex \
&& rm -r /usr/src/ruby \
\
&& gem update --system 2.7.7 \
&& gem install bundler --version 1.16.3 --force \
&& gem install bundler --version 1.16.4 --force \
&& rm -r /root/.gem

RUN SHELLCHECK_VERSION=v0.5.0 \
Expand All @@ -98,4 +98,15 @@ RUN TEST_REPORTER_URL=https://codeclimate.com/downloads/test-reporter/test-repor
&& wget -O /usr/local/bin/cc-test-reporter $TEST_REPORTER_URL \
&& chmod +x /usr/local/bin/cc-test-reporter

RUN apk add --no-cache sudo shadow

RUN adduser -h /home/docker -D -s /bin/bash docker \
&& echo '%docker ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN mkdir /byebug && chown -R docker:docker /byebug

WORKDIR /byebug

COPY docker/bin/entrypoint.sh /usr/local/bin/entrypoint.sh

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
10 changes: 10 additions & 0 deletions docker/bin/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh -x

USER_UID=$(stat -c %u /byebug/Gemfile)
USER_GID=$(stat -c %g /byebug/Gemfile)

usermod -u "$USER_UID" docker
groupmod -g "$USER_GID" docker
usermod -g "$USER_GID" docker

/usr/bin/sudo -EH -u docker "$@"
16 changes: 16 additions & 0 deletions docker/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def push
end

class << self
def build_default
default_image.build
end

def test_default
default_image.test
end

def push_default
default_image.push
end

def build_all
for_all_images(&:build)
end
Expand Down Expand Up @@ -122,6 +134,10 @@ def for_all_images
end
end
end

def default_image
new(version: VERSIONS.last, line_editor: "readline", compiler: "gcc")
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion tasks/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def applicable_files
end

def clean?(file)
in_exec_folder = !(%r{\A(exe|bin)/} =~ file).nil?
in_exec_folder = !(%r{(exe|bin)/} =~ file).nil?
executable = File.executable?(file)

(in_exec_folder && executable) || (!in_exec_folder && !executable)
Expand Down