Skip to content

Commit

Permalink
update docker compose file to have two services for dev and production
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jun 8, 2024
1 parent 5b704c4 commit 7a379f2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bin/ontoportal
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ dev() {
fi

echo "Run: bundle exec rails s -b 0.0.0.0 -p 3000"
docker compose run --rm -it --service-ports rails bash -c "(bundle check || bundle install) && bin/rails db:prepare && bundle exec rails s -b 0.0.0.0 -p 3000"
docker compose run --rm -it --service-ports dev bash -c "(bundle check || bundle install) && bin/rails db:prepare && bundle exec rails s -b 0.0.0.0 -p 3000"
}

# Function to handle the "test" option
Expand All @@ -133,7 +133,7 @@ test() {
# Function to handle the "run" option
run() {
echo "Run: $*"
docker compose run --rm -it rails bash -c "$*"
docker compose run --rm -it dev bash -c "$*"
}

# Main script logic
Expand Down
66 changes: 50 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
x-app: &default-app
image: agroportal/ontoportal_web_ui:test
image: agroportal/ontoportal_web_ui:2.8.0
env_file:
- ".env"
tty: true
volumes:
- .:/app
- bundle:/usr/local/bundle
- node:/node_modules
- rails_cache:/app/tmp/cache
- assets:/app/public/assets
- /var/run/docker.sock:/var/run/docker.sock
- .:/app
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
node:
condition: service_started
links:
- db
- cache
environment: &env
BUNDLE_WITHOUT: ''
DB_HOST: db
CACHE_HOST: cache
ports:
- "3000:3000"
tmpfs:
- /tmp
- /app/tmp/pids
Expand All @@ -28,7 +43,7 @@ services:
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 5s
retries: 3
retries: 3

cache:
image: memcached:latest
Expand All @@ -41,40 +56,59 @@ services:
node:
<<: *default-app
command: "yarn build --watch"
depends_on:
- cache
- db

rails:
dev:
<<: *default-app

production:
<<: *default-app
command: "bundle exec puma -C config/puma.rb"
environment:
<<: *env
RAILS_ENV: "appliance"
BUNDLE_WITHOUT: "development test"
#SECRET_KEY_BASE: TODO
#RAILS_MASTER_KEY: TODO
BIOPORTAL_WEB_UI_DATABASE_PASSWORD: root
MEMCACHE_SERVERS: 'cache:11211'
depends_on:
db:
condition: service_healthy
cache:
condition: service_started
node:
condition: service_started
links:
- db
- cache
environment:
BUNDLE_WITHOUT: ''
DB_HOST: db
CACHE_HOST: cache
ports:
- "3000:3000"
volumes:
- bundle:/usr/local/bundle
- node:/node_modules
- rails_cache:/app/tmp/cache
- assets:/app/public/assets
- app_ui:/app

test:
<<: *default-app
depends_on:
- db
- cache
- chrome-server
network_mode: 'host'
environment:
BUNDLE_WITHOUT: ''
DB_HOST: 127.0.0.1
CACHE_HOST: 127.0.0.1

chrome-server:
image: selenium/standalone-chrome:112.0-chromedriver-112.0-grid-4.9.0-20230421
shm_size: 2g
ports:
- "4444:4444"
- "7900:7900"

volumes:
mysql-data:
bundle:
rails_cache:
assets:
node:
app_ui:

0 comments on commit 7a379f2

Please sign in to comment.