Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

[WIP] docker setup and ruby 2.5.1. #183

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.2
2.5.1
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ruby:2.5.1
MAINTAINER [email protected]

# Install apt based dependencies required to run Rails as
# well as RubyGems. As the Ruby image itself is based on a
# Debian image, we use apt-get to install those.
RUN apt-get update && apt-get install -y \
postgresql-client \
build-essential \
locales \
nodejs

# Use en_US.UTF-8 as our locale
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
RUN echo "LANG=en_US.UTF-8" > /etc/locale.conf
RUN locale-gen en_US.UTF-8
RUN dpkg-reconfigure --frontend=noninteractive locales

# Make /app our working directory.
RUN mkdir -p /app
WORKDIR /app

# Install bundler and make sure that the gems are cached
# at /cache/bundle.
ENV BUNDLE_PATH /cache/bundle
RUN gem install bundler

# Copy the main application.
COPY . ./

# Expose port 3000 to the Docker host, so we can access it
# from the outside.
EXPOSE 3000

# Configure an entry point, so we don't need to specify
# "bundle exec" for each of our commands.
ENTRYPOINT ["./bin/docker/run"]
7 changes: 7 additions & 0 deletions bin/docker/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if bundle check &> /dev/null; then
bundle exec "$@"
else
exec "$@"
fi
7 changes: 7 additions & 0 deletions bin/docker/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

bundle check || bundle install --jobs 5

yarn check || yarn install

bundle exec rails server -b 0.0.0.0
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "2"
services:
postgres:
image: postgres:10-alpine
volumes:
- .:/app
ports:
- "5432:5432"
app:
build: .
command: ./bin/docker/start
volumes:
- .:/app
volumes_from:
- cache
environment:
- WITHIN_DOCKER=1
- PGHOST=postgres
- PGUSER=postgres
ports:
- "3000:3000"
depends_on:
- postgres
cache:
image: busybox
volumes:
- /cache