This document explain the structure and tools that was used in deployment of the solution.
A virtual machine deploy at AZURE with Ubuntu 18.04, separate the Back-End, the Front-End and the Database with dockers.
- Docker
docker pull images1:tag
docker pull images2:tag docker pull images3:tag
- After run the necessary pulls, you will see three images, and we need to create the containers
- MySQL image
docker run --name mysql5 -e MYSQL_ROOT_PASSWORD=your_password -d mysql:latest
You will need check your container IPdocker inspect mysql5
In the last part you will find a part "NetworkSettings" a here there is an IP:"IPAddress": "172.17.0.2",
- Back-End image
docker run -it -p 3000:3000 alejandroreyrios/hackenglish /bin/bash -l
- Front-End image
docker run -it -p 80:4200 -p 172.17.0.2:80 alejandroreyrios/hackenglishfront /bin/bash -l
If you are inside the container you will exit with the command Ctrl + p + q
Modify the access to the database because by default use the local DB /config/database.yml
, example.
default: &default adapter: mysql2 encoding: unicode host: 172.17.0.2 port: 5432` usarname: <% ENV["POSTGRES_USER"] %> password: <% ENV["POSTGRES_PASSWORD"] %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
- Add
gem 'rails_12factor'
to your Gemfile. This will add error logging and the ability for your app to serve static assets. bundle install
- Run
RAILS_ENV=production rake db:create db:migrate db:seed
- Run
rake secret
and copy the output - From the command line:
export SECRET_KEY_BASE=output-of-rake-secret
- To precompile your assets, run
rake assets:precompile
. This will create a folderpublic/assets
that contains all of your assets. - Run
bundle exec rails s -p 3000 -b '0.0.0.0'
and you should see your app.
If you need to update the app, first stop the the service of the Back-End container:
docker attach <name_container>
to connect to the containerCtrl + C
(to stop the service)git "command"
(to update the files)RAILS_ENV=production bundle exec rails s -p 3000 -b '0.0.0.0'
(to start the service again)- Rxit container with
Ctrl p + q