Skip to content
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
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tmp/
node_modules/

##################################
#
#
# rest is COPIED from .gitignore
#
##################################
Expand Down Expand Up @@ -62,4 +62,4 @@ package-lock.json
/public/sitemap.xml.gz

# Development Docker storage location
_docker-storage/
# _docker-storage/
2 changes: 2 additions & 0 deletions Procfile.local_prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: bundle exec rails server -p 3000
worker: bundle exec rake jobs:work
49 changes: 49 additions & 0 deletions _Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM alpine:latest

LABEL Alec Pervushin <alec.for.public@gmail.com>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice email 👍


ENV RUBY_INSTALL_VERSION "0.7.0"
ENV RUBY_INSTALL_URL "https://github.com/postmodern/ruby-install/archive/v${RUBY_INSTALL_VERSION}.tar.gz"
ENV CHRUBY_VERSION '0.3.9'
ENV CHRUBY_URL "https://github.com/postmodern/chruby/archive/v${CHRUBY_VERSION}.tar.gz"

RUN apk update && \
apk upgrade && \
apk add --no-cache gnupg curl bash procps musl zlib openssl \
patch make gcc g++ gnupg musl-dev linux-headers zlib-dev openssl-dev \
postgresql-dev tzdata ruby readline-dev git nodejs yarn

SHELL ["/bin/bash", "-lc"]

WORKDIR /tmp

RUN curl -L -o ruby-install.tar.gz ${RUBY_INSTALL_URL} && \
tar -xzvf ruby-install.tar.gz && \
cd ruby-install-${RUBY_INSTALL_VERSION}/ && make install

ADD _docker-storage/current.tgz* /opt/

COPY _docker-storage/install-railsexpress* /tmp/
COPY .ruby-version* /root/
COPY Gemfile* /tmp/

RUN echo 'export RUBY_VERSION=$([ -z "$RUBY_VERSION" ] && cat ~/.ruby-version || "$RUBY_VERSION")' >> /etc/profile

ENV THREAD_PATCH "https://bugs.ruby-lang.org/attachments/download/7081/0001-thread_pthread.c-make-get_main_stack-portable-on-lin.patch"

RUN ./install-railsexpress railsexpress $RUBY_VERSION \
-p ${THREAD_PATCH} --jobs=2 --cleanup --no-reinstall

RUN curl -L -o chruby.tar.gz ${CHRUBY_URL} && \
tar -xzvf chruby.tar.gz && \
cd chruby-${CHRUBY_VERSION}/ && make install && \
echo "source /usr/local/share/chruby/chruby.sh" >> /etc/profile && \
echo 'chruby $RUBY_VERSION' >> /etc/profile

RUN gem install bundler rb-readline && bundle check || \
bundle install && gem install foreman

RUN apk del gnupg musl-dev linux-headers ruby && \
rm -rf /tmp/* /var/cache/apk/*

COPY _docker-entrypoint.sh* /
145 changes: 145 additions & 0 deletions _docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
version: "3.7"

services:
rails:
build:
context: .
dockerfile: _Dockerfile
stdin_open: true
tty: true
working_dir: /usr/src/app
networks:
courses-network:
aliases:
- rails
ports:
- 127.0.1.1:3000:3000
volumes:
- .:/usr/src/app
- rubies:/opt/rubies
depends_on:
- db
- cache
- arc
environment:
RAILS_ENV: "local_production"
RACK_ENV: "local_production"
DATABASE_URL: "postgres://postgres:password@db/"
MEMCACHIER_SERVERS: "cache"
# ENABLE_HTTPS: "true"
RAILS_SERVE_STATIC_FILES: "true"
RAILS_LOG_TO_STDOUT: "true"
YARN_INTEGRITY_ENABLED: "false"
entrypoint: /_docker-entrypoint.sh
command: "bin/startup"

app:
image: nginx:1.15.12-alpine
depends_on:
- rails
networks:
courses-network:
aliases:
- app
volumes:
- ./_docker-storage/certs:/etc/nginx/certs
- ./_docker-storage/ssl.conf:/etc/nginx/conf.d/ssl.conf
ports:
- 127.0.1.1:3443:443

db:
image: postgres:10-alpine
networks:
courses-network:
aliases:
- db

cache:
image: memcached:1.5.12-alpine
networks:
courses-network:
aliases:
- cache

arc:
image: alpine:latest
volumes:
- rubies:/cont/rubies
- ./_docker-storage:/host/docker
networks:
- courses-network
working_dir: /cont
entrypoint: tar -czf /host/docker/current.tgz rubies/

pghero:
image: ankane/pghero
depends_on:
- db
ports:
- 127.0.1.1:8080:8080
environment:
DATABASE_URL: "postgres://postgres:password@db/PracticalDeveloper_development"
networks:
- courses-network

sitespeed.io:
image: sitespeedio/sitespeed.io
networks:
- courses-network
command: -V
shm_size: 1g
volumes:
- ./sitespeed-result/:/sitespeed.io/sitespeed-result

grafana:
image: grafana/grafana:6.1.6
depends_on:
- graphite
networks:
- courses-network
ports:
- "127.0.1.1:3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=hdeAga76VG6ga7plZ1
- GF_SECURITY_ADMIN_USER=sitespeedio
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_USERS_ALLOW_SIGN_UP=false
- GF_USERS_ALLOW_ORG_CREATE=false
volumes:
- grafana:/var/lib/grafana

graphite:
image: sitespeedio/graphite:1.1.5-3
networks:
- courses-network
ports:
- "127.0.1.1:2003:2003"
- "127.0.1.1:8080:80"
volumes:
# In production you should configure/map these to your container
# Make sure whisper and graphite.db/grafana.db lives outside your containerr
# https://www.sitespeed.io/documentation/sitespeed.io/graphite/#graphite-for-production-important
- whisper:/opt/graphite/storage/whisper
# Download an empty graphite.db from https://github.com/sitespeedio/sitespeed.io/tree/master/docker/graphite
#- ./graphite/graphite.db:/opt/graphite/storage/graphite.db
#- ./graphite/conf/storage-schemas.conf:/opt/graphite/conf/storage-schemas.conf
#- ./graphite/conf/storage-aggregation.conf:/opt/graphite/conf/storage-aggregation.conf
#- ./graphite/conf/carbon.conf:/opt/graphite/conf/carbon.conf
grafana-setup:
image: sitespeedio/grafana-bootstrap:8.14.0
networks:
- courses-network
depends_on:
- grafana
environment:
- GF_PASSWORD=hdeAga76VG6ga7plZ1
- GF_USER=sitespeedio

networks:
courses-network:
name: courses-network

volumes:
rubies:
grafana:
whisper:
6 changes: 6 additions & 0 deletions _docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash -l

chruby

# Execute the given or default command:
exec "$@"
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def icon_url(name)
end

def cloudinary(url, width = nil, _quality = 80, _format = "jpg")
return url if Rails.env.development? && (url.blank? || url.exclude?("http"))
return url if (Rails.env.development? || Rails.env.local_production?) && (url.blank? || url.exclude?("http"))

service_path = "https://res.cloudinary.com/practicaldev/image/fetch"

Expand All @@ -101,7 +101,7 @@ def cloudinary(url, width = nil, _quality = 80, _format = "jpg")
def cloud_cover_url(url)
return if url.blank?
return asset_path("triple-unicorn") if Rails.env.test?
return url if Rails.env.development?
return url if Rails.env.development? || Rails.env.local_production?

width = 1000
height = 420
Expand Down
Loading