Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Compose setup for development #1418

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# syntax=docker/dockerfile:1
ARG BASE_IMAGE=ruby
ARG BASE_TAG=2.7.6-slim
ARG BASE=${BASE_IMAGE}:${BASE_TAG}

FROM ${BASE} AS builder

ENV LANG en_US.UTF-8

RUN apt-get update -qq \
&& apt-get install -y \
build-essential \
ca-certificates \
curl \
tzdata \
git \
libpq-dev \
nodejs \
yarn \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" \
> /etc/apt/sources.list.d/yarn.list \
&& apt-get update -qq \
&& apt-get install -y nodejs yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ARG RAILS_ROOT=/app/

RUN mkdir ${RAILS_ROOT}
WORKDIR ${RAILS_ROOT}

COPY Gemfile* ${RAILS_ROOT}
ADD gems ${RAILS_ROOT}gems

RUN bundle install -j4 --retry 3

COPY package.json yarn.lock ${RAILS_ROOT}
RUN yarn install

COPY . ${RAILS_ROOT}

RUN bundle exec rake assets:precompile

FROM ${BASE}

ENV LANG en_US.UTF-8

RUN apt-get update -qq \
&& apt-get install -y libjemalloc2 postgresql-client tzdata libv8-dev nodejs

RUN groupadd --gid 1000 app && \
useradd --uid 1000 --no-log-init --create-home --gid app app
USER app

COPY --from=builder --chown=app:app /usr/local/bundle/ /usr/local/bundle/
COPY --from=builder --chown=app:app /app /app

ENV RAILS_ENV=development
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_SERVE_STATIC_FILES true
ENV PORT 3000
ARG RAILS_ROOT=/app/

WORKDIR $RAILS_ROOT
RUN mkdir -p tmp/pids
CMD bundle exec puma -p $PORT -C ./config/puma.rb
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3.9"
services:
db:
image: postgres:latest
restart: always
ports:
- "5432:5432"
volumes:
- ~/tmp/houdini/db:/var/lib/postgresql/data
environment:
- POSTGRES_USER=houdini_user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=houdini_development
web:
build: .
volumes:
- .:/app
ports:
- "3000:3000"
environment:
- DATABASE_HOST=db
depends_on:
- db