Last active
March 6, 2024 13:58
-
-
Save dweidner/872f426e784a08e5e591096d5e9e6df4 to your computer and use it in GitHub Desktop.
Docker-based Ruby development environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bundle | |
.git | |
.gitignore | |
.env* | |
!.env.example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "example" | |
services: | |
ruby: | |
build: | |
context: . | |
args: | |
- "RUBY_VERSION=${RUBY_VERSION:-2.7.8}" | |
- "BUNDLER_VERSION=${BUNDLER_VERSION:-2.4.22}" | |
- "UID=${UID:-1000}" | |
- "GID=${GID:-1000}" | |
command: "bundle exec jekyll serve --watch --host 0.0.0.0 --port 4000" | |
restart: "unless-stopped" | |
tty: true | |
init: true | |
env_file: | |
- path: ".env" | |
required: false | |
ports: | |
- "${FORWARD_APP_PORT:-4000}:4000" | |
volumes: | |
- ".:/app" | |
- "/usr/local/bundle/gems" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# syntax=docker/dockerfile:1.4 | |
ARG DEBIAN_RELEASE="bookworm" | |
ARG RUBY_VERSION="3.3" | |
FROM ruby:${RUBY_VERSION}-slim-${DEBIAN_RELEASE} | |
LABEL maintainer="Daniel Weidner <[email protected]>" | |
LABEL org.label-schema.schema-version="1.0" | |
LABEL org.label-schema.name="ruby" | |
LABEL org.label-schema.description="Example Dockerfile to setup a ruby development environment with bundler" | |
LABEL org.label-schema.docker.cmd="docker run -d -v .:/app -v /usr/local/bundle/gems ruby bundle install" | |
ARG RUBY_VERSION | |
ARG BUNDLER_VERSION="2.5.6" | |
ARG UID=1000 | |
ARG GID=1000 | |
ENV RUBY_VERSION="${RUBY_VERSION}" | |
ENV BUNDLER_VERSION="${BUNDLER_VERSION}" | |
RUN <<-EOR | |
set -e | |
apt-get update | |
apt-get install --yes --no-install-recommends build-essential=12.9 | |
apt-get clean | |
rm -rf /var/lib/apt/lists/* use/share/doc /usr/share/man | |
groupadd -g "${GID}" ruby | |
useradd --create-home --no-log-init -u "${UID}" -g "${GID}" ruby | |
EOR | |
USER ruby | |
WORKDIR /app | |
COPY --link --chown=ruby:ruby Gemfile Gemfile.lock ./ | |
RUN <<-EOR | |
set -e | |
gem install bundler -v "${BUNDLER_VERSION}" | |
bundle check || bundle install | |
EOR | |
CMD ["irv"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment