From 8d860dea30a768313dfc65a06415d73d4106ef71 Mon Sep 17 00:00:00 2001 From: Nikolay Voynov Date: Tue, 12 Dec 2023 08:02:23 +0200 Subject: [PATCH] v0.6.4 --- CHANGELOG.md | 7 +++++-- lib/assets/starter/.dockerignore | 12 ++++++++++++ lib/assets/starter/Dockerfile | 13 +++++++------ lib/assets/starter/Rakefile | 3 ++- lib/assets/starter/docker.rake | 24 ++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 lib/assets/starter/.dockerignore create mode 100644 lib/assets/starter/docker.rake diff --git a/CHANGELOG.md b/CHANGELOG.md index 333c9c0..f765dd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,12 @@ title: Punch Changelog ## [Unreleased] -## [0.6.4] - 2023-12-09 +## [0.6.4] - 2023-12-12 -- moved to Ruby 3.2.2 +- moved to Ruby 3.2.2 (Psych and Tests) +- added .dockerignore +- added doker.rake +- changed Dockerfile ## [0.6.3] - 2023-01-24 diff --git a/lib/assets/starter/.dockerignore b/lib/assets/starter/.dockerignore new file mode 100644 index 0000000..8eb1b8a --- /dev/null +++ b/lib/assets/starter/.dockerignore @@ -0,0 +1,12 @@ +# Ignore all +* + +# Allow sources +!/exe/service.rb +!/app +!/lib +# !Gemfile +# !Gemfile.lock + +# Ignore inside sources +**/*~ diff --git a/lib/assets/starter/Dockerfile b/lib/assets/starter/Dockerfile index cc4eebb..2a4e437 100644 --- a/lib/assets/starter/Dockerfile +++ b/lib/assets/starter/Dockerfile @@ -1,6 +1,7 @@ -FROM ruby:latest -WORKDIR /usr/src/app/ -RUN bundle install -ADD . /usr/src/app/ -EXPOSE 3333 -CMD ["ruby", "/usr/src/app/hello.rb"] +FROM ruby:3.2.2 +WORKDIR /app +# COPY Gemfile Gemfile.lock . +# ENV BUNDLER_WITHOUT development test +# RUN gem update --system && bundle install +ADD . . +CMD ["ruby", "/app/exe/service.rb"] diff --git a/lib/assets/starter/Rakefile b/lib/assets/starter/Rakefile index a06b1c5..9a56106 100644 --- a/lib/assets/starter/Rakefile +++ b/lib/assets/starter/Rakefile @@ -1,6 +1,7 @@ # frozen_string_literal: true - +require "rake" require "rake/testtask" +Rake.application.rake_require "docker", ["."] Rake::TestTask.new(:test) do |t| t.libs << "test" diff --git a/lib/assets/starter/docker.rake b/lib/assets/starter/docker.rake new file mode 100644 index 0000000..b5e4f43 --- /dev/null +++ b/lib/assets/starter/docker.rake @@ -0,0 +1,24 @@ +namespace :docker do + + DOCKER = 'docker'.freeze + + desc 'Up mounted /app' + task :local do + # for Docker on Windows, add folder (Settings->Resources->File Sharing) and retart Docker + # docker run --rm -it --mount type=bind,source=.,destination=/app ruby:3.2.2 /bin/sh + system "#{DOCKER} run --rm -it --mount type=bind,source=.,destination=/app ruby:3.2.2 /bin/sh" + end + + desc "Build Docker Image" + task :build, :tag do |t, args| + args.with_defaults(tag: 'dummy') + system "#{DOCKER} build . -t #{args.tag}" + end + + desc "Run Docker Image" + task :run, :command do |t, args| + args.with_defaults(command: '') # /bin/sh + system "#{DOCKER} run --rm -it --mount type=bind,source=.,destination=/app dummy #{args.command}" + end + +end