From 5b506a2daa25ee6d35127ecb635020ec6d6b8eb0 Mon Sep 17 00:00:00 2001 From: Robert Starmer Date: Tue, 14 Mar 2023 14:14:02 -0700 Subject: [PATCH 1/3] add D-in-D dockerfile, update Readme --- Dockerfile.dind | 33 +++++++++++++++++++++++++++++++++ README.md | 16 ++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.dind diff --git a/Dockerfile.dind b/Dockerfile.dind new file mode 100644 index 00000000..d0c9d90a --- /dev/null +++ b/Dockerfile.dind @@ -0,0 +1,33 @@ +# Use the official Docker docker-in-docker Alpine image as the base image +FROM docker:dind + +# 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 system dependencies including ruby-dev +RUN apk add --no-cache --update ruby-dev build-base git docker openrc \ + && rc-update add docker boot \ + && gem install bundler --version=2.4.3 \ + && bundle install + +# 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 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"] diff --git a/README.md b/README.md index 168bed4c..7d4f69c5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,19 @@ Watch the screencast: https://www.youtube.com/watch?v=LL1cV2FXZ5I ## Installation -Install MRSK globally with `gem install mrsk`. Then, inside your app directory, run `mrsk init` (or `mrsk init --bundle` within Rails apps where you want a bin/mrsk binstub). Now edit the new file `config/deploy.yml`. It could look as simple as this: +Install MRSK globally with `gem install mrsk` or build a dockerized version: + +```sh +docker build . -t mrsk:dind -t mrsk:latest -f Dockerfile.dind +``` + +If you build the docker version, add the following alias to your .${SHELL}rc file and re-source the rc file to allow ssh and docker to work within the container: + +```sh +alias mrsk='docker run --rm -it -v $HOME/.ssh:/root/.ssh -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/:/workdir mrsk' +``` + +Then, inside your app directory, run `mrsk init` (or `mrsk init --bundle` within Rails apps where you want a bin/mrsk binstub). Now edit the new file `config/deploy.yml`. It could look as simple as this: ```yaml service: hey @@ -34,7 +46,7 @@ mrsk deploy This will: 1. Connect to the servers over SSH (using root by default, authenticated by your ssh key) -2. Install Docker on any server that might be missing it (using apt-get) +2. Install Docker on any server that might be missing it (using apt-get): root access is needed via ssh for this. 3. Log into the registry both locally and remotely 4. Build the image using the standard Dockerfile in the root of the application. 5. Push the image to the registry. From 11af999800ea127ea8f60f44ba13cd8b79211567 Mon Sep 17 00:00:00 2001 From: Robert Starmer Date: Tue, 14 Mar 2023 16:27:19 -0700 Subject: [PATCH 2/3] Remove unneeded Dockerfile.dind, update Readme --- Dockerfile.dind | 33 --------------------------------- README.md | 2 +- 2 files changed, 1 insertion(+), 34 deletions(-) delete mode 100644 Dockerfile.dind diff --git a/Dockerfile.dind b/Dockerfile.dind deleted file mode 100644 index d0c9d90a..00000000 --- a/Dockerfile.dind +++ /dev/null @@ -1,33 +0,0 @@ -# Use the official Docker docker-in-docker Alpine image as the base image -FROM docker:dind - -# 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 system dependencies including ruby-dev -RUN apk add --no-cache --update ruby-dev build-base git docker openrc \ - && rc-update add docker boot \ - && gem install bundler --version=2.4.3 \ - && bundle install - -# 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 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"] diff --git a/README.md b/README.md index e4ef3060..b842ee69 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Join us on Discord: https://discord.gg/DQETs3Pm Install MRSK globally with `gem install mrsk` or build a dockerized version: ```sh -docker build . -t mrsk:dind -t mrsk:latest -f Dockerfile.dind +docker build . -t mrsk:latest -f Dockerfile ``` If you build the docker version, add the following alias to your .${SHELL}rc file and re-source the rc file to allow ssh and docker to work within the container: From cf38feb1d64a390b75dda50ba635bded71a4279c Mon Sep 17 00:00:00 2001 From: Robert Starmer Date: Thu, 23 Mar 2023 12:35:15 -0700 Subject: [PATCH 3/3] Update readme to point to ghcr.io/mrsked/mrsk --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b842ee69..11405674 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ Join us on Discord: https://discord.gg/DQETs3Pm ## Installation -Install MRSK globally with `gem install mrsk` or build a dockerized version: +If you have a ruby environment available, you can install MRSK globally with ```sh -docker build . -t mrsk:latest -f Dockerfile +gem install mrsk ``` -If you build the docker version, add the following alias to your .${SHELL}rc file and re-source the rc file to allow ssh and docker to work within the container: +or run a dockerized version via an alias (add this to your ${SHELL}rc to simplify re-use): ```sh -alias mrsk='docker run --rm -it -v $HOME/.ssh:/root/.ssh -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/:/workdir mrsk' +alias mrsk='docker run --rm -it -v $HOME/.ssh:/root/.ssh -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}/:/workdir ghcr.io/mrsked/mrsk' ``` Then, inside your app directory, run `mrsk init` (or `mrsk init --bundle` within Rails apps where you want a bin/mrsk binstub). Now edit the new file `config/deploy.yml`. It could look as simple as this: