Last active
February 10, 2020 22:16
-
-
Save wshihadeh/037be6c2a714b4c7c6ab38b201bccbe2 to your computer and use it in GitHub Desktop.
Precompile on the host
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
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 |
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
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: |
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
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; | |
} | |
} |
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
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