Created
December 22, 2021 14:02
-
-
Save RyanSnodgrass/c8f85b94e0a2c921deff521560db37c9 to your computer and use it in GitHub Desktop.
Example Dockerfile and Compose for Fenrir
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" | |
networks: | |
fenrir_user: | |
services: | |
redis: | |
image: redis:alpine | |
command: redis-server | |
ports: | |
- 6379:6379 | |
volumes: | |
- redis_data:/data:cached | |
logging: | |
driver: none | |
networks: | |
- fenrir_user | |
# docker-compose exec redis redis-cli | |
nginx: | |
image: fenrir_nginx | |
restart: always | |
build: | |
context: . | |
dockerfile: ./nginx/Dockerfile.nginx | |
depends_on: | |
- app | |
networks: | |
- fenrir_user | |
expose: | |
- 443 | |
ports: | |
- 80:80 | |
- 8080:8080 | |
- 4443:443 | |
volumes_from: | |
- app | |
neo4j: | |
# When you change the neo4j version, you will need to recrete the volume. | |
# `docker volume rm fenrir_neo4j_rspec_data` | |
image: neo4j:3.5.27 | |
ports: | |
- 7474:7474 # http://0.0.0.0:7474/ | |
- 7687:7687 # bolt | |
expose: | |
- 7474 | |
- 7687 | |
volumes: | |
- neo4j_app_data:/data | |
environment: | |
NEO4J_AUTH: none | |
# Use the built in neo4j-admin tool on the docker container to get a | |
# memory recommendation. Neo4j needs a couple gigs and the ruby app needs | |
# 1 or 2 gigs. Docker containers pool their memory together and by default | |
# Neo4j is greedy thinking it's being given _all_ of it. Set the memory max | |
# to about 3/4 of pooled memory. | |
# `neo4j-admin memrec --memory=6g` | |
NEO4J_dbms_memory_heap_initial__size: 3g | |
NEO4J_dbms_memory_heap_max__size: 3g | |
NEO4j_dbms_memory_pagecache_size: 1g | |
restart: on-failure | |
networks: | |
- fenrir_user | |
healthcheck: | |
test: wget http://localhost:7474 || exit 1 | |
interval: 1s | |
timeout: 10s | |
retries: 20 | |
start_period: 3s | |
app: | |
build: . | |
image: fenrir_app | |
command: tail -F init.sh | |
# command: bundle exec unicorn -c /vagrant/fenrir/config/unicorn.rb | |
volumes: | |
- .:/vagrant/fenrir:cached | |
- /var/sockets | |
ports: | |
- 3000:3001 | |
env_file: | |
- .env.local | |
depends_on: | |
redis: | |
condition: service_started | |
neo4j: | |
condition: service_healthy | |
elastic: | |
condition: service_started | |
environment: | |
REDIS_URL: redis://redis:6379 | |
ELASTICSEARCH_URL: elastic:9200 | |
NEO4J_URL: http://neo4j:7474 | |
# development, development_remote, staging, staging_remote, production | |
RAILS_ENV: localhost | |
networks: | |
- fenrir_user | |
elastic: # 2.4.6 | |
image: elasticsearch:2.4.6 | |
ports: | |
- 9200:9200 | |
- 9300:9300 | |
expose: | |
- 9200 | |
- 9300 | |
environment: | |
# To run the Elasticsearch 7 Docker image in development mode, you should | |
# set discovery.type to single-node. At startup, the bootstrap checks are | |
# bypassed. The single node will elect itself as the master node and will | |
# not join a cluster with any other node. | |
- xpack.security.enabled=false | |
- discovery.type=single-node | |
# - xpack.monitoring.enabled=false | |
# - xpack.graph.enabled=false | |
# - xpack.watcher.enabled=false | |
ulimits: | |
memlock: | |
soft: -1 | |
hard: -1 | |
nofile: | |
soft: 65536 | |
hard: 65536 | |
cap_add: | |
- IPC_LOCK | |
logging: | |
driver: none | |
volumes: | |
- elasticsearch-data:/usr/share/elasticsearch/data | |
networks: | |
- fenrir_user | |
volumes: | |
redis_data: | |
neo4j_app_data: | |
elasticsearch-data: | |
driver: local | |
# docker-compose up --detach |
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 ruby:2.4.10 AS ruby-base | |
##########==============================########## | |
# install bundler version that matches Gemfile | |
RUN gem install bundler -v '1.17.3' | |
# throw errors if Gemfile has been modified since Gemfile.lock | |
# RUN bundle config --global frozen 1 | |
WORKDIR /vagrant/fenrir | |
# Pre-install large gems early in dockerfile stack to make `bundle install` | |
# command faster | |
RUN gem install nokogiri -v '1.10.10' | |
RUN gem install mimemagic -v '0.3.9' | |
RUN gem install sassc -v '2.4.0' | |
# Update Debian repository information and all installed packages | |
RUN apt-get update | |
##########==============================########## | |
FROM ruby-base AS oracle-install | |
##########==============================########## | |
# Silence debconf frontend warnings | |
# RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | |
ENV DEBIAN_FRONTEND=noninteractive | |
# Install Oracle Instant Client necessary packages | |
# RUN apt-get install -y apt-utils | |
# RUN apt-get install -y build-essential | |
RUN apt-get install -y libpq-dev | |
RUN apt-get install -y libaio1 | |
RUN apt-get install -y alien | |
RUN apt-get install -y unixodbc-dev | |
RUN apt-get install -y libc6 | |
RUN mkdir /opt/oracle | |
# Install ruby-odbc gem | |
RUN gem install ruby-odbc -v '0.999991' | |
# Instant Client | |
ADD https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-\ | |
instantclient-basic-21.1.0.0.0-1.x86_64.rpm /opt/oracle/ | |
RUN alien -i --scripts /opt/oracle/oracle-instantclient-basic-21.1.0.0.0-1.x86_64.rpm | |
# SDK | |
ADD https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-\ | |
instantclient-devel-21.1.0.0.0-1.x86_64.rpm /opt/oracle | |
RUN alien -i --scripts /opt/oracle/oracle-instantclient-devel-21.1.0.0.0-1.x86_64.rpm | |
# SqlPlus | |
ADD https://download.oracle.com/otn_software/linux/instantclient/211000/oracle-\ | |
instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm /opt/oracle | |
RUN alien -i --scripts /opt/oracle/oracle-instantclient-sqlplus-21.1.0.0.0-1.x86_64.rpm | |
# Install ruby-oci8 gem | |
# RUN cd /opt/oracle/instantclient_21_1 && ln -s libclntsh.so.12.1 libclntsh.so | |
# ENV LD_LIBRARY_PATH /usr/lib/oracle/21/client64/lib/ | |
ENV NLS_LANG American_America.UTF8 | |
RUN gem install ruby-oci8 -v '2.2.9' | |
# Copy .ora config files and set system variables | |
COPY config/ldap.ora /usr/lib/oracle/21/client64/lib/network/admin | |
COPY config/sqlnet.ora /usr/lib/oracle/21/client64/lib/network/admin | |
ENV TNS_ADMIN /usr/lib/oracle/21/client64/lib/network/admin | |
ENV ORACLE_HOME /usr/lib/oracle/21/client64/lib/ | |
RUN chmod 755 /usr/lib/oracle/21/client64/lib/network/admin/* | |
ENV PATH="/usr/lib/oracle/21/client64/bin:${PATH}" | |
##########==============================########## | |
FROM oracle-install AS app-install | |
##########==============================########## | |
# copy ruby version and Gemfile later in the docker build | |
COPY .ruby-version Gemfile Gemfile.lock ./ | |
# specify which and where the Gemfile is | |
ENV BUNDLE_GEMFILE /vagrant/fenrir/Gemfile | |
# install gems | |
RUN bundle install | |
# expose unicorn and nginx ports | |
EXPOSE 3001 4443 443 | |
# rails uses a pid folder | |
RUN mkdir /tmp/pid | |
# unicorn uses a socket | |
RUN mkdir /var/sockets | |
# ENTRYPOINT ["/bin/bash"] | |
# CMD ["rails", "server", "-b", "0.0.0.0", "-p", "3000"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment