Forem is built using Ruby on Rails but if you were to SSH into your Forem Server you may have a hard time finding it.
That is because Forem is running in containers via Podman.
So you can see all of the resources running on your Forem server by running:
sudo podman ps -a
Which will list containers
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5712942bcb9 k8s.gcr.io/pause:3.5 About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp ff711bf9eef1-infra
29a1cb7fe232 docker.io/darthsim/imgproxy:v2 imgproxy About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-imgproxy
94977d75c1ce docker.io/library/postgres:11 postgres About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-postgresql
9bc4592eeb54 docker.io/library/redis:6.0.1 redis-server --ap... About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-redis
d7bdd1f6baae localhost/forem/forem:current bundle exec rails... About a minute ago Up About a minute ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-rails
e990ee4624ea localhost/forem/forem:current bundle exec sidek... About a minute ago Up 58 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-worker
2fa68d8d5c2b quay.io/forem/openresty:1.17.8.2 /usr/bin/openrest... 55 seconds ago Up 55 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-openresty
4e2db20b2690 docker.io/library/traefik:2.3.0 traefik 48 seconds ago Up 48 seconds ago 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp forem-traefik
Now you shouldn't need to modify a Ruby on Rails running in production, but there are rare instances you may need to debug an issue, like say you are not sure if you Rails server is working so you want to access rails console.
Similar to Docker we can use the exec
command to run bash
to access these pods:
podman exec -it <Container ID> /bin/bash
You can either provide the Container ID or Container Name.
So to access the Ruby on Rails server you can type:
sudo podman exec -it forem-rails /bin/bash
Once you're inside you can ls and see the contents of the Rails app right there.
bash-5.0$ ls
CODE_OF_CONDUCT.md FOREM_BUILD_SHA Procfile SECURITY.md config.ru datadog jest.config.js postcss.config.js svgo.config.js
CONTRIBUTING.md Gemfile Procfile.dev app container-compose.yml db jsconfig.json postcss_error.log testSetup.js
Containerfile Gemfile.lock Procfile.dev-hot babel.config.js cypress docker-compose.yml lib public tmp
Dockerfile Guardfile README.md bin cypress.dev.json docs log release-tasks.sh vendor
FOREM_BUILD_DATE LICENSE.md Rakefile config cypress.json empty-module.js package.json scripts yarn.lock
A common tool to debug rails app is rails console
which is an interactive shell with your Rails environment loaded.
bash-5.0$ RAILS_ENV=production bin/rails console
Loading production environment (Rails 6.1.4)
irb(main):001:0> Rails.env
=> "production"
Another easy check is to send a GET request to the homepage via Curl:
bash-5.0$ curl -I localhost
HTTP/1.1 308 Permanent Redirect
Location: https://localhost/
Date: Thu, 22 Jul 2021 20:33:58 GMT
Content-Length: 18
Content-Type: text/plain; charset=utf-8
So this shows us that the ruby server is taking in requests and giving back a response.
To exit console just type exit
To exit the pod back to your Forem OS type exit
If you are just looking to access Rails Console Forem has their own convient tool called ForemCtl
so you can just type:
foremctl console
Its the same as logging into a pod and running bin/rails console
Top comments (0)