From 57b1a474fe63ecf31679b8dc1dc96e327de18aec Mon Sep 17 00:00:00 2001 From: Rasmus <2277443+kjellberg@users.noreply.github.com> Date: Fri, 3 Mar 2023 23:57:07 +0100 Subject: [PATCH 1/3] Create Dockerfile --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..121a0d7f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# Use the official Ruby 3.2.0 Alpine image as the base image +FROM ruby:3.2.0-alpine + +# Install system dependencies +RUN apk add --no-cache build-base + +RUN gem install bundler --version=2.4.3 + +# Create a directory for your application +RUN mkdir -p /mrsk + +# Set the working directory to /mrsk +WORKDIR /mrsk + +# Copy the Gemfile, Gemfile.lock into the container +COPY Gemfile Gemfile.lock mrsk.gemspec ./ + +# Required in mrsk.gemspec +COPY lib/mrsk/version.rb /mrsk/lib/mrsk/version.rb + +# Install gems +RUN bundle install + +# Copy the rest of your application code into the container +COPY . . + +# Install the gem locally from the project folder +RUN gem build mrsk.gemspec && \ + gem install ./mrsk-*.gem --no-document + +# Set the entrypoint to run the installed binary +ENTRYPOINT ["mrsk"] \ No newline at end of file From 81cbd760d53fdd87f1724493c742a576c3133b70 Mon Sep 17 00:00:00 2001 From: Rasmus <2277443+kjellberg@users.noreply.github.com> Date: Sat, 4 Mar 2023 07:38:29 +0100 Subject: [PATCH 2/3] Group RUN commands - reduce image size --- Dockerfile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 121a0d7f..a863e197 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,6 @@ # Use the official Ruby 3.2.0 Alpine image as the base image FROM ruby:3.2.0-alpine -# Install system dependencies -RUN apk add --no-cache build-base - -RUN gem install bundler --version=2.4.3 - -# Create a directory for your application -RUN mkdir -p /mrsk - # Set the working directory to /mrsk WORKDIR /mrsk @@ -18,15 +10,25 @@ COPY Gemfile Gemfile.lock mrsk.gemspec ./ # Required in mrsk.gemspec COPY lib/mrsk/version.rb /mrsk/lib/mrsk/version.rb -# Install gems -RUN bundle install +# Install system dependencies +RUN apk add --no-cache --update build-base git docker openrc \ + && rc-update add docker boot \ + && gem install bundler --version=2.4.3 \ + && mkdir -p /mrsk \ + && bundle install -# Copy the rest of your application code into the container +# Copy the rest of our application code into the container. +# We do this after bundle install, to avoid having to run bundle +# everytime we do small fixes in the source code. COPY . . # Install the gem locally from the project folder RUN gem build mrsk.gemspec && \ gem install ./mrsk-*.gem --no-document -# Set the entrypoint to run the installed binary -ENTRYPOINT ["mrsk"] \ No newline at end of file +# Set the working directory to /workdir +WORKDIR /workdir + +# Set the entrypoint to run the installed binary in /workdir +# Example: docker run -it -v "$PWD:/workdir" mrsk init +ENTRYPOINT ["mrsk"] From 8faef72d33cdcae3a5ca90aed6fbd251416b51a4 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 4 Mar 2023 08:15:32 +0100 Subject: [PATCH 3/3] Already created by WORKDIR --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a863e197..98dd3c69 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,6 @@ COPY lib/mrsk/version.rb /mrsk/lib/mrsk/version.rb RUN apk add --no-cache --update build-base git docker openrc \ && rc-update add docker boot \ && gem install bundler --version=2.4.3 \ - && mkdir -p /mrsk \ && bundle install # Copy the rest of our application code into the container.