This is an opinionated gist just to show that it's possible to start a ruby gem development work using Docker (I don't want any ruby installation in my manjaro laptop).
To generate a new gem in linux you can use the following command (if you're using MacOS there is no need to use --user
flag):
docker run --rm -it -w /app -v ${PWD}:/app ruby:slim bash -c "bundle gem newgem && chown -R $(id -u):$(id -g) ./newgem"
Then you can use the following Dockerfile to start the gem development work:
FROM ruby:slim
WORKDIR /app
# Add build-essential if you need some compiled gems
RUN bash -c "set -o pipefail && apt-get update \
&& apt-get install -y --no-install-recommends git build-essential"
RUN git config --global --add safe.directory /app
COPY . .
RUN bin/setup
CMD ["bin/console"]
And the following docker-compose file:
version: '3.4'
services:
newgem:
image: newgem
container_name: newgem
build:
context: ./newgem
dockerfile: ../Dockerfile
volumes:
- ./newgem:/app
- gems_cache:/usr/local/bundle
volumes:
gems_cache:
You need to adjust the gemspec file to edit the "TODO" strings and set the URLs required fields (homepage_uri, source_code_uri, changelog_uri) and then make a first commit inside the newgem folder.
Your project structure would be:
Then, you need to udpate the newgem.gemspec
file setting the proper URLs and removing all TODO text
Then, create the docker image:
docker-compose build
Finally you can start your development work: