Last active
October 4, 2016 16:08
-
-
Save braidn/a9153ae007f7d7303171537b09a37884 to your computer and use it in GitHub Desktop.
Current Docker Exploration
This file contains 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
version: '2' | |
services: | |
db: | |
image: kiasaki/alpine-postgres | |
volumes: | |
- ./pgdata:/pgdata | |
ports: | |
- "5432:5432" | |
environment: | |
POSTGRES_DB: quarterly_development | |
POSTGRES_USER: postgres | |
PGDATA: /pgdata | |
redis: | |
image: redis | |
web: | |
build: . | |
links: | |
- db | |
- redis | |
volumes: | |
- .:/home/quarterly/repo | |
- ./keys:/root/.ssh/ | |
ports: | |
- '9393:9393' | |
env_file: | |
- .env | |
environment: | |
REDIS_URL: redis://redis:6379 | |
restart: always | |
command: foreman start |
This file contains 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
FROM ruby:2.1.8-alpine | |
MAINTAINER DW & Braidn <itsallbroken@godynamo.com> | |
# Env | |
ENV REFRESHED_AT 2016-09-21 | |
ENV PROJECT_NAME quarterly | |
ENV REPO_DIR /home/$PROJECT_NAME/repo | |
ENV GEM_HOME /home/$PROJECT_NAME/gems | |
ENV ENV_FILE /home/$PROJECT_NAME/repo/.env | |
ENV BUILD_PACKAGES bash libffi-dev openssl-dev linux-headers zlib-dev readline-dev yaml-dev git curl-dev ruby-dev build-base | |
ENV RUBY_PACKAGES ruby-io-console ruby-bundler nodejs libxml2-dev libxslt-dev postgresql-dev | |
# Build all required packages | |
RUN apk update && \ | |
apk upgrade && \ | |
apk add $BUILD_PACKAGES && \ | |
apk add $RUBY_PACKAGES && \ | |
rm -rf /var/cache/apk/* | |
# Create and switch to repo dir | |
RUN mkdir -p $GEM_HOME $REPO_DIR | |
WORKDIR $REPO_DIR | |
# Copy the rest of the app | |
ADD . $REPO_DIR | |
# Symlink vendor | |
RUN ln -sn /home/$PROJECT_NAME/repo/vendor/bundle $GEM_HOME | |
# Install gems. Bundler won't allow us to install with documentation. | |
#### NOTE: In production, the bundle command should be appended with `--without development test` | |
COPY Gemfile* $REPO_DIR/ | |
# Nokogiri FTW | |
RUN bundle config build.nokogiri --use-system-libraries | |
# Set some defaults for bundler | |
ENV BUNDLE_GEMFILE=$REPO_DIR/Gemfile \ | |
BUNDLE_JOBS=6 \ | |
BUNDLE_PATH=$GEM_HOME | |
# Bundle ALL the gems | |
RUN gem install bundler && gem install tzinfo-data && bundle install | |
# Provide a Healthcheck for Docker risk mitigation | |
HEALTHCHECK --interval=3600s --timeout=20s --retries=2 CMD curl http://localhost:3000 || exit 1 | |
# Define an entrypoint for default | |
ENTRYPOINT ["bundle", "exec"] | |
# Default command, running app as a service | |
CMD ["bundle", "exec", "foreman", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What's the elevator pitch for using the Alpine distro vs Ubuntu?