Last active
July 20, 2017 02:43
-
-
Save appkr/c891902e70e3717235ffae83cf4cb7e0 to your computer and use it in GitHub Desktop.
RoR Docker template
This file contains hidden or 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
generate(:scaffold, "post", "title:string", "body:text") | |
file 'config/database.yml', <<-CODE | |
default: &default | |
adapter: mysql2 | |
encoding: utf8 | |
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> | |
host: db | |
username: <%= ENV.fetch('MYSQL_USER') %> | |
password: <%= ENV.fetch('MYSQL_PASSWORD') %> | |
development: | |
<<: *default | |
database: ror_docker | |
test: | |
<<: *default | |
database: ror_docker | |
production: | |
<<: *default | |
database: ror_docker | |
CODE | |
file 'Dockerfile', <<-CODE | |
FROM ruby:2.3-alpine | |
# ------------------------------------------------------------------------------ | |
# Set timezone | |
# ------------------------------------------------------------------------------ | |
RUN apk add --update tzdata \ | |
&& cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime \ | |
&& echo "Asia/Seoul" > /etc/timezone; | |
# ------------------------------------------------------------------------------ | |
# Install banaries | |
# ------------------------------------------------------------------------------ | |
RUN apk add --update --virtual \ | |
runtime-deps \ | |
mysql-client \ | |
nodejs \ | |
libffi-dev \ | |
readline \ | |
sqlite; | |
# ------------------------------------------------------------------------------ | |
# Install gems | |
# ------------------------------------------------------------------------------ | |
WORKDIR /tmp | |
ADD Gemfile* ./ | |
RUN apk add --virtual \ | |
build-deps \ | |
build-base \ | |
openssl-dev \ | |
libc-dev \ | |
linux-headers \ | |
libxml2-dev \ | |
libxslt-dev \ | |
readline-dev \ | |
&& bundle install --jobs=2 \ | |
&& apk del build-deps; | |
# ------------------------------------------------------------------------------ | |
# Copy application into the container | |
# ------------------------------------------------------------------------------ | |
COPY . /app | |
WORKDIR /app | |
# ------------------------------------------------------------------------------ | |
# Publish ENV vars | |
# ------------------------------------------------------------------------------ | |
ENV RAILS_ENV=production \ | |
RACK_ENV=production | |
# ------------------------------------------------------------------------------ | |
# Expose port | |
# ------------------------------------------------------------------------------ | |
EXPOSE 3000 | |
# ------------------------------------------------------------------------------ | |
# Run puma | |
# ------------------------------------------------------------------------------ | |
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] | |
CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment