Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy RoR app from Azure DevOps to Linux Server

Andriy asked in General

Hi all.
Have some problem.
I'm newest in Azure DevOps (AD).

I created AD git repository for RoR project.
Created pipeline for master branch:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

steps:
- task: UseRubyVersion@0
  inputs:
    versionSpec: '= 2.5.5'
    addToPath: true

- script: |
    sudo apt install freetds-dev
    sudo apt install libpq-dev
    sudo apt install sqlite3 libsqlite3-dev
    sudo apt install postgresql postgresql-contrib
  displayName: 'lib for tiny_tds, postgres'

- script: |
    sudo -i -u postgres psql -c "CREATE USER user WITH PASSWORD 'pppppp';"
    sudo -i -u postgres psql -c "ALTER USER user WITH SUPERUSER;"
    sudo -i -u postgres psql -c "CREATE DATABASE db WITH OWNER = user;"
    sudo -i -u postgres psql -c "CREATE DATABASE db_test WITH OWNER = user;"
  displayName: 'create pg user & db'

- script: |
    echo "gem: --no-document" > ~/.gemrc
    gem install bundler
    bundle install --retry=3 --jobs=4
  displayName: 'bundle install'

- script: rails db:migrate RAILS_ENV=test
  displayName: 'db migrate ENV=test'

- script: bundle exec rake
  displayName: 'bundle exec rake'

- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/TEST-*.xml'
    failTaskOnFailedTests: true

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(agent.builddirectory)'
    Contents: '**'
    TargetFolder: '$(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

Successfully passed the tests in pipeline above.

And...
How now use releases & environments for deploy project to linux server? How use pipeline above and created artifact?
I don't want use Azure Subscription. Maybe Kubernetes...
The main question is where I can compile ruby project and how deploy it on server? How automate this process?
Who can help with advice, tutorial, documentations?

Thanks all!

Reply

I used your above script to install postgres in AZ Devops Pipeline..

it is failing in

- script: |
    sudo -i -u postgres psql -c "CREATE USER user WITH PASSWORD 'pppppp';"
    sudo -i -u postgres psql -c "ALTER USER user WITH SUPERUSER;"
    sudo -i -u postgres psql -c "CREATE DATABASE db WITH OWNER = user;"
    sudo -i -u postgres psql -c "CREATE DATABASE db_test WITH OWNER = user;"
  displayName: 'create pg user & db'

With Below error
psql: error: could not connect to server: No such file or directory

Can i also know what host config you gave in your database.yml file.

Thanks in advance.

Reply

Hi Andriy, were you able to deploy on a vm? I am also trying to deploy my ruby on rails web app from azure devops to a vm with ubuntu? I would really appreciate the help.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,651+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.