Skip to content

Commit

Permalink
Merge pull request #71 from FDA/origin/Sep2022
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
lorenbuhle authored Sep 7, 2022
2 parents 96ea649 + 99cdff8 commit 92c9088
Show file tree
Hide file tree
Showing 26 changed files with 1,350 additions and 284 deletions.
3 changes: 3 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Important note

Before editing **any** of the `docker-compose.yml` files please read ["docker compose guide"](../docs/DOCKER_COMPOSE_GUIDE.md)
115 changes: 115 additions & 0 deletions docker/arm64v8.dev.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
version: '3.7'

# NOTE(samuel) - docs - volumes have to always be in leaf docker compose files
volumes:
bundler-deps-cache-ruby:
db-pfda-mysql-volume:
webpack-cache-client:
yarn-network-cache-client:
yarn-network-cache-nodejs-api:
yarn-network-cache-nodejs-worker:
yarn-deps-cache-client:
yarn-deps-cache-nodejs-api:
yarn-deps-cache-nodejs-worker:

services:
web:
extends:
file: ./base.services.yml
service: web
build:
context: ../
dockerfile: docker/images/isolation.arm64v8.Dockerfile
environment:
- ARM64V8_DEVELOPMENT_PATCH=1
- RAILS_ENV=development
- SKIP_RUBY_DEPS_SETUP=${SKIP_RUBY_DEPS_SETUP}
- SKIP_DB_SETUP=${SKIP_DB_SETUP}
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle
- db-pfda-mysql-volume:/var/lib/mysql
frontend:
extends:
file: ./base.services.yml
service: frontend
build:
context: ../client
dockerfile: ./docker/images/isolation.arm64v8.dev.Dockerfile
environment:
- SKIP_FRONTEND_DEPS_SETUP=${SKIP_FRONTEND_DEPS_SETUP}
volumes:
- type: volume
source: webpack-cache-client
target: /precision-fda/.build_cache/
- type: bind
source: ../client/src
target: /precision-fda/src
- yarn-network-cache-client:${YARNV1_CACHE_DIR}
- yarn-deps-cache-client:/precision-fda/node_modules
nodejs-api:
extends:
file: ./base.services.yml
service: nodejs-api
build:
context: ../
dockerfile: ./https-apps-api/docker/images/node.isolated-dev.Dockerfile
command: ['make', 'watch']
environment:
- NODE_ENV=development
- NODE_DATABASE_NAME=precision-fda
- NODE_DATABASE_URL=mysql://root:password@db:3306/precision-fda
- SKIP_NODEJS_DEPS_SETUP=${SKIP_NODEJS_DEPS_SETUP}
volumes:
- type: bind
source: ../https-apps-api/packages
target: /app/packages
- yarn-network-cache-nodejs-api:${YARNV1_CACHE_DIR}
- yarn-deps-cache-nodejs-api:/app/node_modules

nodejs-worker:
extends:
file: ./base.services.yml
service: nodejs-worker
build:
context: ../
dockerfile: ./https-apps-api/docker/images/node.isolated-dev.Dockerfile
command: ['make', 'watch-worker']
environment:
- NODE_ENV=development
- NODE_DATABASE_NAME=precision-fda
- NODE_DATABASE_URL=mysql://root:password@db:3306/precision-fda
- SKIP_NODEJS_DEPS_SETUP=${SKIP_NODEJS_DEPS_SETUP}
volumes:
- type: bind
source: ../https-apps-api/packages
target: /app/packages
- yarn-network-cache-nodejs-worker:${YARNV1_CACHE_DIR}
- yarn-deps-cache-nodejs-worker:/app/node_modules
db:
extends:
file: ./base.services.yml
service: db_emulated
volumes:
- db-pfda-mysql-volume:/var/lib/mysql
redis:
extends:
file: ./base.services.yml
service: redis
sidekiq:
extends:
file: ./base.services.yml
service: sidekiq
build:
context: ../
dockerfile: docker/images/isolation.arm64v8.Dockerfile
environment:
- ARM64V8_DEVELOPMENT_PATCH=1
- RAILS_ENV=development
- SKIP_RUBY_DEPS_SETUP=${SKIP_RUBY_DEPS_SETUP}
- SKIP_DB_SETUP=${SKIP_DB_SETUP}
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle
67 changes: 67 additions & 0 deletions docker/arm64v8.qa.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: '3.7'

# ! Write a documentation note
# NOTE(samuel): docker volumes cannot be defined in abstract files
volumes:
bundler-deps-cache-ruby:
db-pfda-mysql-volume:
webpack-cache-client:

services:
web:
extends:
file: ./base.services.yml
service: web
build:
context: ../
dockerfile: docker/images/isolation.arm64v8.Dockerfile
environment:
- RAILS_ENV=ui_test
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle
- db-pfda-mysql-volume:/var/lib/mysql

frontend:
extends:
file: ./base.services.yml
service: frontend
build:
context: ../client
dockerfile: ./docker/images/isolation.arm64v8.Dockerfile
volumes:
- type: volume
source: webpack-cache-client
target: /precision-fda/.build_cache/
nodejs-api:
extends:
file: ./base.services.yml
service: nodejs-api
nodejs-worker:
extends:
file: ./base.services.yml
service: nodejs-worker
db:
extends:
file: ./base.services.yml
service: db_emulated
volumes:
- db-pfda-mysql-volume:/var/lib/mysql
redis:
extends:
file: ./base.services.yml
service: redis
sidekiq:
extends:
file: ./base.services.yml
service: sidekiq
build:
context: ../
dockerfile: docker/images/isolation.arm64v8.Dockerfile
environment:
- RAILS_ENV=ui_test
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle
94 changes: 94 additions & 0 deletions docker/base.services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
services:
base_ruby:
build:
context: ../
dockerfile: docker/images/isolation.Dockerfile
args:
- RUBY_IMAGE_TAG=2.7.5
environment:
- RAILS_LOG_TO_STDOUT=1
- LOG_REQUESTS=1
- NO_FIPS=1
- REDIS_WORKER_URL=redis://redis:6379/0
base_nodejs:
build:
context: ../
dockerfile: ./https-apps-api/docker/images/node.isolated-qa.Dockerfile
args:
- NODEJS_IMAGE_TAG=12.22.10

web:
extends:
service: base_ruby
volumes:
- type: bind
source: ../
target: /precision-fda
working_dir: /precision-fda
ports:
- 3000:3000
depends_on:
- db
- redis
- sidekiq
entrypoint: ./docker/entrypoint/isolation.docker-entrypoint.sh

frontend:
build:
context: ../client
dockerfile: ./docker/images/isolation.Dockerfile
args:
- FRONTEND_IMAGE_TAG=12
volumes:
- type: bind
source: ../app/assets/packs/bundle.js
target: /precision-fda/dist/bundle.js
working_dir: /precision-fda
command: yarn watch:docker
# TODO(samuel) setup correct NODE_ENV here
nodejs-api:
extends:
service: base_nodejs
command: ['make', 'run-dist']
ports:
- 3001:3001
depends_on:
- db
- redis
nodejs-worker:
extends:
service: base_nodejs
command: ['make', 'run-worker-dist']
depends_on:
- db
- redis
sidekiq:
extends:
service: base_ruby
volumes:
- type: bind
source: ../
target: /precision-fda
entrypoint: docker/entrypoint/sidekiq.entrypoint.sh
depends_on:
- redis
db:
# ! Don't forget to update "db_emulated" image when updating version
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
ports:
- 32800:3306

redis:
image: redis:5.0
ports:
- 6379:6379

# Emulated images
# Note - it's better to keep this in this file as all the versions are at the same place

db_emulated:
extends:
service: db
image: amd64/mysql:5.7
57 changes: 57 additions & 0 deletions docker/dev.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
version: '3.7'

volumes:
bundler-deps-cache-ruby:
db-pfda-mysql-volume:
webpack-cache-client:

services:
web:
extends:
file: ./base.services.yml
service: web
environment:
- RAILS_ENV=development
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle
- db-pfda-mysql-volume:/var/lib/mysql
frontend:
extends:
file: ./base.services.yml
service: frontend
volumes:
- type: volume
source: webpack-cache-client
target: /precision-fda/.build_cache/
command: yarn watch:docker
nodejs-api:
extends:
file: ./base.services.yml
service: nodejs-api
nodejs-worker:
extends:
file: ./base.services.yml
service: nodejs-worker
db:
extends:
file: ./base.services.yml
service: db
volumes:
- db-pfda-mysql-volume:/var/lib/mysql
redis:
extends:
file: ./base.services.yml
service: redis
sidekiq:
extends:
file: ./base.services.yml
service: sidekiq
environment:
- RAILS_ENV=development
volumes:
- type: volume
source: bundler-deps-cache-ruby
target: /usr/local/bundle

8 changes: 8 additions & 0 deletions docker/entrypoint/docker-test-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

cp config/database.sample.yml config/database.yml

service mysql start

bundle exec rake db:setup
bundle exec rake
24 changes: 24 additions & 0 deletions docker/entrypoint/isolation.docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

sed -i '/^#/!s/CipherString = DEFAULT@SECLEVEL=2/#CipherString = DEFAULT@SECLEVEL=2/g' /etc/ssl/openssl.cnf

dockerize -wait tcp://db:3306

cp config/database.sample.yml config/database.yml

if [[ ! $SKIP_RUBY_DEPS_SETUP || $SKIP_RUBY_DEPS_SETUP = 0 ]]; then
bundle check || bundle install
fi

if [[ ! $SKIP_DB_SETUP || $SKIP_DB_SETUP = 0 ]]; then
# Runs setup if database does not exist, or runs migrations if it does
bundle exec rake db:prepare

bundle exec rake user:generate_test_users
fi

if [[ -f ./key.pem && -f ./cert.pem ]]; then
bundle exec thin --debug start --ssl --ssl-key-file ./key.pem --ssl-cert-file ./cert.pem
else
bundle exec thin --ssl --debug start
fi
9 changes: 9 additions & 0 deletions docker/entrypoint/sidekiq.entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

sed -i '/^#/!s/CipherString = DEFAULT@SECLEVEL=2/#CipherString = DEFAULT@SECLEVEL=2/g' /etc/ssl/openssl.cnf

# Install gems if needed
bundle check || bundle install

# Run sidekiq
bundle exec sidekiq
Loading

0 comments on commit 92c9088

Please sign in to comment.