Skip to content

Instantly share code, notes, and snippets.

@yottanami
Created December 12, 2017 11:52
Show Gist options
  • Save yottanami/8265f58df15849de9cba3668618496dd to your computer and use it in GitHub Desktop.
Save yottanami/8265f58df15849de9cba3668618496dd to your computer and use it in GitHub Desktop.
#######################dockerfile-image###############
FROM nginx
# Install dependencies
RUN apt-get update -qq && apt-get -y install apache2-utils
# establish where Nginx should look for files
ENV RAILS_ROOT /var/www/sample_rails_docker_app
# Set our working directory inside the image
WORKDIR $RAILS_ROOT
# create log directory
RUN mkdir log
# copy over static assets
COPY public public/
# Copy Nginx config template
COPY config/nginx.conf /tmp/docker_example.nginx
# substitute variable references in the Nginx config template for real values from the environment
# put the final config in its place
RUN envsubst '$RAILS_ROOT' < /tmp/docker_example.nginx > /etc/nginx/conf.d/default.conf
#RUN rm -rf /etc/nginx/sites-available/default
#ADD config/nginx.conf /etc/nginx/sites-enabled/nginx.conf
EXPOSE 80
# Use the "exec" form of CMD so Nginx shuts down gracefully on SIGTERM (i.e. `docker stop`)
CMD [ "nginx", "-g", "daemon off;" ]
############################dockerfile########
FROM ruby:2.3.3
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR /myapp
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
ENV RAILS_ENV production
RUN gem install gentelella-rails -v '0.1.10'
RUN bundle install
COPY . /myapp
RUN bundle exec rake SECRET_KEY_BASE=pickasecuretoken2 assets:precompile
#####################docker-compose###################
version: '3'
services:
app:
build: .
#command: bundle exec rails s -p 3000 -b '0.0.0.0'
command: bundle exec puma -C config/puma.rb
stdin_open: true
tty: true
volumes:
- ./file_storage:/myapp
- assets:/myapp/public/assets/
environment:
- SECRET_KEY_BASE=weqwewqewqewqe
expose:
- "3000"
ports:
- "27017:27017"
network_mode: "host"
web:
build:
context: .
dockerfile: Dockerfile-nginx
links:
- app
ports:
- "80:5050"
volumes:
assets:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment