diff --git a/README.md b/README.md index 149f12f7..be85c969 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,15 @@ Help would be appreciated! Please join us in [slack #flaredown](https://rubyforg * Redis 6.2.3 * Ruby 3.0.6 (see [RVM](https://rvm.io/) also) * Node 12.22.6 + ## Installation +All dependencies are dockerized, including the application and can be run using `docker compose` so there's no dependencies to install other than docker. + +If you want to run the application on your own machine see the next sections on dependency installations + +### Mac + _If you are running on an M1 mac, run the following command before you start the installation process:_ ```bash $env /usr/bin/arch -arm64 /bin/zsh ---login @@ -54,7 +61,22 @@ npm install ## Running / Development +### Docker + From the project root: + +```bash +docker compose --profile dev up +``` + +This will build and run all the containers necessary to run the application locally. + +Visit your app at [http://localhost:4300](http://localhost:4300) + +### Local Machine Installation + +From the project root: + ```bash docker compose up ``` @@ -63,8 +85,6 @@ docker compose up rake run ``` -Visit your app at [http://localhost:4300](http://localhost:4300) - ## CI Several checks are configured to run on all commits using Github Actions, including lint, build and test steps. Definitions can be found in [./github/workflows](./github/workflows). Those checks which always run are required to be successful for PRs to be mergable. diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 00000000..b0aacb5c --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,23 @@ +FROM ruby:3.0 + +# set working directory +WORKDIR /app + +# install dependencies +RUN apt-get update -qq && \ + apt-get install -y nodejs postgresql-client + +# install bundler +RUN gem install bundler:2.1.4 + +# copy the Gemfile and Gemfile.lock to the container +COPY Gemfile Gemfile.lock ./ + +# install the gems +RUN bundle install + +# copy the rest of the application files to the container +COPY . . + +# start the server +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] diff --git a/backend/config/database.yml b/backend/config/database.yml index 14a1979c..42fe57ac 100644 --- a/backend/config/database.yml +++ b/backend/config/database.yml @@ -1,7 +1,7 @@ default: &default adapter: postgresql encoding: unicode - host: localhost + host: <%= ENV.fetch('PG_DATABASE_HOST') { 'localhost' } %> database: flaredown_development username: postgres password: password diff --git a/backend/config/mongoid.yml b/backend/config/mongoid.yml index 0fdae284..dd6ced10 100644 --- a/backend/config/mongoid.yml +++ b/backend/config/mongoid.yml @@ -9,7 +9,7 @@ development: # Provides the hosts the default client can connect to. Must be an array # of host:port pairs. (required) hosts: - - localhost:27017 + - <%= ENV['MONGODB_HOST'] || "localhost" %>:27017 options: # Change the default write concern. (default = { w: 1 }) # write: diff --git a/docker-compose.yml b/docker-compose.yml index af7157d4..aa9f722a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,87 @@ -version: '3' -volumes: - postgres: - mongodb: - redis: +version: '3.8' +x-backend-services-hosts: + &backend-services-hosts + MONGODB_HOST: mongodb + REDIS_URL: redis://redis:6379 + PG_DATABASE_HOST: postgres + services: + backend: + build: backend + depends_on: + - postgres + - mongodb + - redis + ports: + - 3000:3000 + volumes: + - ./backend:/app + environment: *backend-services-hosts + profiles: + - dev + workers: + build: backend + command: bundle exec sidekiq -C config/sidekiq.yml + depends_on: + - redis + - mongodb + - postgres + volumes: + - ./backend:/app + environment: *backend-services-hosts + profiles: + - dev + tunnel: + build: backend + command: bundle exec bin/localtunnel + depends_on: + - backend + volumes: + - ./backend:/app + profiles: + - tunnel + frontend: + build: frontend + depends_on: + - backend + ports: + - 4300:4300 + volumes: + - ./frontend:/app + command: sh -c "cd /app && rm -rfd ./dist && ./node_modules/.bin/ember serve --port 4300 --proxy http://localhost:3000" + profiles: + - dev + app-setup: + build: backend + command: bundle exec rails app:setup + depends_on: + - postgres + environment: *backend-services-hosts + profiles: + - tools postgres: image: postgres:12.8-alpine + restart: always environment: POSTGRES_PASSWORD: password PGDATA: /data volumes: - postgres:/data - ports: - - 5432:5432 + expose: + - 5432 mongodb: image: mongo:4.4.9 volumes: - mongodb:/data/db - ports: - - 27017:27017 + expose: + - 27017 redis: image: redis:6.2.3-alpine volumes: - redis:/data - ports: - - 6379:6379 + expose: + - 6379 +volumes: + postgres: + mongodb: + redis: diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 00000000..177477ae --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1,8 @@ +bower_components +node_modules +dist +tmp +.git +README.md +LICENSE +.gitignore diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 00000000..d8fcec61 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,14 @@ +FROM node:12.22.6 + +# Force npm version 7 +RUN npm i -g npm@7 + +WORKDIR /app + +COPY package*.json bower.json .bowerrc .npmrc ./ + +RUN npm install + +COPY . . + +CMD ["npm", "start"] diff --git a/frontend/README.md b/frontend/README.md index d8d740dd..be4431d9 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -23,7 +23,7 @@ You will need the following things properly installed on your computer. ## Running / Development * `ember serve` -* Visit your app at [http://localhost:4200](http://localhost:4200). +* Visit your app at [http://localhost:4300](http://localhost:4300). ## Running / Development via Fastboot server @@ -54,4 +54,3 @@ Specify what it takes to deploy your app. * Development Browser Extensions * [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) * [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) -