Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Last active February 10, 2020 22:16
Show Gist options
  • Save wshihadeh/037be6c2a714b4c7c6ab38b201bccbe2 to your computer and use it in GitHub Desktop.
Save wshihadeh/037be6c2a714b4c7c6ab38b201bccbe2 to your computer and use it in GitHub Desktop.
Precompile on the host
FROM wshihadeh/rails-base-image-ruby:2.6.5-mysql
LABEL maintainer="Al-waleed Shihadeh <[email protected]>"
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
USER rails
WORKDIR /application
RUN bundle config build.nokogiri --use-system-libraries && \
bundle config git.allow_insecure true && \
bundle config set deployment 'true' && \
bundle config set frozen 'true' && \
bundle config set without 'development test' && \
bundle install --quiet && \
mkdir tmp/pids && \
rm -rf vendor/cache/*.gem
CMD web
version: '3.7'
services:
mysql:
image: mysql:5.7
command: mysqld --general-log=1 --general-log-file=/var/log/mysql/general-log.log
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: dummy
MYSQL_DATABASE: rails_blog_production
rails_blog_web:
build:
context: rails_blog
dockerfile: Dockerfile
restart: always
command: 'web'
ports:
- 8080:8080
depends_on:
- mysql
environment:
DATABASE_URL: mysql2://root:dummy@mysql/rails_blog_production
web:
build:
context: .
dockerfile: ./nginx/Dockerfile
command: server
ports:
- 80:80
volumes:
db_data:
server {
listen 80 default_server;
server_name blog.*;
root /var/www//public;
index index.html;
location ~ /\. {
deny all;
}
location ~* ^.+\.(rb|log)$ {
deny all;
}
# serve static (compiled) assets directly if they exist (for rails production)
location ~ ^/(assets|images|javascripts|stylesheets|swfs|system)/ {
try_files $uri @rails;
access_log off;
gzip_static on;
# to serve pre-gzipped version
expires max;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
location / {
try_files $uri @rails;
}
location @rails {
resolver 127.0.0.11 ipv6=off;
set $target http://rails_blog_web:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass $target;
}
}
From nginx:latest
LABEL maintainer="Al-waleed <[email protected]>"
COPY ./nginx/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
RUN mkdir /var/www/
WORKDIR /var/www/
COPY ./rails_blog/public public/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment