Last active
March 18, 2022 07:58
-
-
Save dieter-medium/7c1325443266392405fe912a873360a0 to your computer and use it in GitHub Desktop.
A docker compose environment for Ruby on Rails development
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
#!/usr/bin/env bash | |
if [ ! -x "$(command -v docker)" ]; then | |
echo "Docker not found. Please check your PATH, or install docker" | |
exit 1 | |
fi | |
SCRIPT_PATH=$(dirname "$0") | |
docker compose -f ${SCRIPT_PATH}/../docker/docker-compose.yml -f ${SCRIPT_PATH}/../docker/docker-compose.rubymine.yml "$@" |
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.9" | |
services: | |
mailhog: | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.mailhog.service=mailhog" | |
- "traefik.http.routers.mailhog.rule=Host(`mailhog.localtest.me`)" | |
- "traefik.http.routers.mailhog.entrypoints=web" | |
- "traefik.http.services.mailhog.loadbalancer.server.port=8025" | |
adminer: | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.adminer.service=adminer" | |
- "traefik.http.routers.adminer.rule=Host(`adminer.localtest.me`)" | |
- "traefik.http.routers.adminer.entrypoints=web" | |
- "traefik.http.services.adminer.loadbalancer.server.port=8080" | |
web: | |
ports: | |
- "127.0.0.1:1234:1234" | |
- "127.0.0.1:26166:26168" | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.rails.service=rails" | |
- "traefik.http.routers.rails.rule=Host(`rails.localtest.me`)" | |
- "traefik.http.routers.rails.entrypoints=web" | |
- "traefik.http.services.rails.loadbalancer.server.port=3000" | |
reverse-proxy: | |
image: traefik:v2.6 | |
command: | |
- "--api" | |
- "--api.dashboard=true" | |
- "--accesslog=true" | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.web.address=:80" | |
- "--entrypoints.web-secured.address=:443" | |
- "--log.level=${TRAEFIK_LOG_LEVEL-INFO}" | |
ports: | |
- "${TRAEFIK_EXT_HTTP_PORT-9080}:80" | |
- "${TRAEFIK_EXT_HTTPS_PORT-9083}:443" | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.api.entrypoints=web-secured" | |
- "traefik.http.routers.api.tls=true" | |
- "traefik.http.routers.api.rule=Host(`proxy.localtest.me`) && (PathPrefix(`/api/`) || PathPrefix(`/dashboard/`))" | |
- "traefik.http.routers.api.service=api@internal" | |
- "traefik.http.routers.api.middlewares=auth" | |
- "traefik.http.middlewares.auth.basicauth.users=${TRAEFIK_ADMIN_CREDS-admin:$$apr1$$sPGZMz2Z$$RkYE0FoYzrFD599h7fx/r1}" | |
volumes: | |
- /var/run/docker.sock:/var/run/docker.sock |
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.9" | |
services: | |
adminer: | |
image: adminer | |
restart: "unless-stopped" | |
ports: | |
- 9090:8080 | |
mailhog: | |
image: mailhog/mailhog | |
ports: | |
- "1025:1025" | |
- "8025:8025" | |
logging: | |
driver: none | |
db: | |
image: mysql:8 | |
restart: "unless-stopped" | |
environment: | |
HISTFILE: /root/histfiles/.bash_history_mysql | |
MYSQL_ROOT_PASSWORD: <password> | |
MYSQL_DATABASE: app | |
MYSQL_USER: appuser | |
MYSQL_PASSWORD: <password> | |
volumes: | |
- ../data/mysql:/var/lib/mysql:cached | |
- ../data/histfiles:/root/histfiles:cached | |
ports: | |
- "3307:3306" | |
web: | |
build: | |
context: .. | |
dockerfile: docker/Dockerfile.dev | |
command: tail -f /dev/null | |
environment: | |
HISTFILE: /root/histfiles/.bash_history_rails | |
volumes: | |
- ..:/myapp:cached | |
- /myapp/node_modules | |
- ../data/histfiles:/root/histfiles:cached | |
ports: | |
- "3000:3000" | |
depends_on: | |
- db |
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
#!/usr/bin/env bash | |
SCRIPT_PATH=$(dirname "$0") | |
cd ${SCRIPT_PATH}/.. | |
rm -f tmp/pids/server.pid | |
echo "Bundle" | |
bundle check || bundle install | |
echo "Yarn" | |
yarn install | |
echo "Prepare DB" | |
bin/rails db:prepare | |
echo "Cleanups" | |
bin/rails log:clear tmp:clear | |
echo "Start dev env" | |
bin/dev |
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
ARG RUBY_VERSION=3.1.0-jemalloc | |
FROM quay.io/evl.ms/fullstaq-ruby:2.7.5-jemalloc-bullseye-slim | |
RUN apt-get update -qq && apt-get install -y nodejs npm default-mysql-client default-libmysqlclient-dev libsqlite3-dev build-essential libxml2 libxml2-dev zlib1g-dev libxslt-dev git procps wget | |
RUN apt-get update -qq && apt-get install -y libvips | |
RUN wget --no-verbose -O /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_93.0.4577.82-1_amd64.deb && apt install -y /tmp/chrome.deb | |
RUN npm install --global yarn | |
WORKDIR /myapp | |
COPY Gemfile /myapp/Gemfile | |
COPY Gemfile.lock /myapp/Gemfile.lock | |
RUN bundle install | |
RUN gem install rubocop standardrb | |
RUN gem install bundle-audit | |
COPY docker/entrypoint.sh /usr/bin/ | |
RUN chmod +x /usr/bin/entrypoint.sh | |
ENTRYPOINT ["entrypoint.sh"] | |
EXPOSE 3000 | |
CMD ["rails", "server", "-b", "0.0.0.0"] |
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
#!/bin/bash | |
set -e | |
rm -f /myapp/tmp/pids/server.pid | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanations can be found