Skip to content

Instantly share code, notes, and snippets.

@jfroom
Created March 15, 2017 22:03
Show Gist options
  • Save jfroom/709e0f562e1cb54e556329e875012af3 to your computer and use it in GitHub Desktop.
Save jfroom/709e0f562e1cb54e556329e875012af3 to your computer and use it in GitHub Desktop.
DC-Bundler
FROM ruby:2.3-slim
RUN apt-get update && apt-get install -qq -y --no-install-recommends build-essential
# Ensure that our apt package list is updated and has basic build packages.
RUN mkdir -p /app
WORKDIR /app
COPY . .
# Add app files into docker image
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
# Add bundle entry point to handle bundle cache
ENV BUNDLE_PATH=/bundle \
BUNDLE_BIN=/bundle/bin \
GEM_HOME=/bundle
ENV PATH="${BUNDLE_BIN}:${PATH}"
# Bundle installs with binstubs to our custom /bundle/bin volume path.
# Let system use those stubs.
#!/bin/bash
# Interpreter identifier
set -e
# Exit on fail
bundle check || bundle install --binstubs="$BUNDLE_BIN"
# Ensure all gems installed. Add binstubs to bin which has been added to PATH in Dockerfile.
exec "$@"
# Finally call command issued to the docker service
version: '3.1'
services:
web:
build: .
command: "echo 'Insert a Gemfile dependent startup command here, like \"rails server\".'"
ports:
- '3000:3000'
volumes:
- bundle_cache:/bundle
# Map bundle cache to named volume
- .:/app
# Map /app files back to host drive, and visa versa
volumes:
bundle_cache:
# Mount volume with default driver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment