Skip to content

Instantly share code, notes, and snippets.

@dsalahutdinov
Last active May 25, 2021 21:02
Show Gist options
  • Save dsalahutdinov/2d8975347ec79e94e7674dd0d9d4c518 to your computer and use it in GitHub Desktop.
Save dsalahutdinov/2d8975347ec79e94e7674dd0d9d4c518 to your computer and use it in GitHub Desktop.
Dockerize Ruby backend of the multi-service application for local development
services:
app: &app
build:
context: .
dockerfile: Dockerfile.dev
args:
PG_VERSION: '9.6'
image: amplifr-dev:0.1.0
volumes:
- .:/app:cached
- bundle:/bundle
environment:
# environment settings
- BUNDLE_PATH=/bundle
- BUNDLE_CONFIG=/app/.bundle/config
- RAILS_ENV=${RAILS_ENV:-development}
- DATABASE_URL=postgresql://postgres@postgres/amplifr_${RAILS_ENV}
- REDIS_URL=redis://redis:6379/
# service integrations
- FRONTEND_URL=https://frontend-server:3001/
- LOGUX_URL=http://logux-server:31338
depends_on:
- postgres
- redis
tmpfs:
- /tmp
runner:
<<: *app
stdin_open: true
tty: true
command: /bin/bash
networks:
default:
internal:
server:
<<: *app
stdin_open: true
tty: true
command: bundle exec thin start
networks:
default:
internal:
aliases:
- backend-server
ports:
- '3000:3000'
sidekiq:
<<: *app
command: sidekiq
postgres:
image: postgres:9.6
volumes:
- postgres:/var/lib/postgresql/data
ports:
- 5432
redis:
image: redis:3.2-alpine
volumes:
- redis:/data
ports:
- 6379
volumes:
postgres:
redis:
bundle:
networks:
internal:
FROM ruby:2.6.1
ARG PG_VERSION
ARG NODE_VERSION
ARG TINI_VERSION=v0.18.0
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo 'deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main' $PG_VERSION > /etc/apt/sources.list.d/pgdg.list \
&& curl -o /tmp/nodejs.deb https://deb.nodesource.com/node_11.x/pool/main/n/nodejs/nodejs_$NODE_VERSION-1nodesource1_amd64.deb \
&& apt-get update -qq \
&& apt-get install -yq --no-install-recommends \
build-essential \
less \
vim \
postgresql-client-$PG_VERSION \
/tmp/nodejs.deb \
libidn11-dev libldap2-dev \
fontconfig \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY ./app/assets/fonts/Helvetica.ttf /usr/share/fonts/truetype/Helvetica.ttf
RUN fc-cache -vf
RUN npm install phantomjs-prebuilt \
&& ln -s /node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /usr/local/bin/phantomjs \
&& rm -rf /tmp/phantomjs
ENV LANG=C.UTF-8 \
GEM_HOME=/bundle \
BUNDLE_JOBS=4 \
BUNDLE_RETRY=3
ENV BUNDLE_PATH $GEM_HOME
ENV BUNDLE_APP_CONFIG=$BUNDLE_PATH \
BUNDLE_BIN=$BUNDLE_PATH/bin
ENV PATH $BUNDLE_BIN:$PATH
RUN mkdir -p /app
WORKDIR /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment