1

I have a containerized rails application, deployed on a app service in Azure. I've enabled SSH for my docker in order to manually run some rakes, and execute rails CLI commands.

The issue: Logging in through the SSH in azure portal does not let me run any commands (rakes, migrates etc).

I always run into the command not found error, even though the application is successfully deployed and running, so that must mean rails and all the gems are installed somewhere. The bundler is installed in the docker container, along with ruby.

My dockerfile:

FROM ruby:2.6.3

....

WORKDIR /app
COPY . /app

ENV RAILS_ENV production
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true

ADD Gemfile /app
ADD Gemfile.lock /app
RUN gem install bundler
RUN bundle config set --local without 'test' --with runtime --deployment
RUN bundle install

EXPOSE 3000 80 2222

RUN ["chmod","+x","entrypoint.sh"]

ENTRYPOINT ["./entrypoint.sh"]

Any help is highly appreciated!

I've tried executing which ruby, and looking in the gems folder but I've only found bundler there. I've tried setting the GEM_HOME and GEM_PATH to point to my local app, but once again the bundler is installed there and all the other gems are missing.

Executing which/locate rails does not find the installation. When I try to run bin/rails, it complains that the other gems are not installed/

What is the issue here? Is there another way I should be doing this through azure?

3
  • If your app works, it means the ruby environment is installed. Did you try bundle exec rake? Also, have you attached to the shell in the container? Commented Nov 11, 2022 at 10:46
  • I have tried bundle exec rake and rails with no luck. When running bundle exec rails s through my entrypoint I have no issues and the server starts, it's just running it through bash that errors out. What do you mean by attached to the shell? Commented Nov 11, 2022 at 11:14
  • Please don't put tags into your title. StackOverflow has a tags system that you're already using, that's where tags should be defined. Commented Nov 15, 2022 at 22:43

1 Answer 1

1

I think that environment variables are not automatically passed on to SSH sessions. I had to add these to my docker image start script

# This makes env variables available in the SSH session too.
eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//=\'\''/' | sed 's/$/\'\''/' >> /etc/profile)

Check this link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.