Reputation: 43
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?
Upvotes: 1
Views: 217
Reputation: 336
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.
Upvotes: 1