Why kamal is trying to run IRB on deploy? #1264
-
I have a trouble since i have been trying to deploy an application with kamal 2 and Rails 8. If i run But when i try to run
if i run
Below is my Dockerfile and docker-compose.yml, i don't think that is a problem with them, but for information purposes: docker-compose.yml services:
redis:
image: "redis:7-alpine"
ports:
- 6379
volumes:
- ./tmp/redis_data:/var/lib/redis/data
db:
image: postgres:14
container_name: myapp-postgres-14.2
environment:
POSTGRES_USERNAME: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
ports:
- "5432:5432"
expose:
- "5432"
web:
build: .
stdin_open: true
tty: true
entrypoint: config/setup_app.sh
command: bash -c "bin/rails s -p 3000 -b '0.0.0.0'"
environment:
REDIS_URL: ${REDIS_URL}
POSTGRES_USERNAME: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
env_file:
- .env
volumes:
- .:/home/app/web
ports:
- "3000:3000"
depends_on:
- db
- redis
volumes:
postgres_data: {}
networks:
default:
name: myapp_default Dockerfile: FROM ruby:3.3.6
RUN apt update
RUN apt upgrade -y
RUN apt install lsb-base lsb-release -y
#Postgres
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt update \
&& apt install -y htop \
nano \
postgresql-14 \
build-essential libssl-dev zlib1g-dev libreadline-dev \
libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev \
libffi-dev software-properties-common
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs
RUN gem install pg
ADD . /home/app/web
WORKDIR /home/app/web
COPY package*.json ./
RUN npm install
RUN bundle install --jobs 5 --retry 5 my entrypoint file, setup_app.sh #! /bin/sh
set -e
bundle check || bundle install --jobs 5 --retry 5
if [ -f tmp/pids/server.pid ]; then
rm tmp/pids/server.pid
fi
echo ' --> Running migrations'
rails db:migrate
echo ' --> End of migrations'
exec "$@" # command from docker-compose.yml and my deploy.yml from kamal config. # Name of your application. Used to uniquely configure containers.
service: myapp
# Name of the container image.
image: myuser/myapp
# Deploy to these servers.
servers:
web:
- 111.111.111.111
# job:
# hosts:
# - 192.168.0.1
# cmd: bin/jobs
# Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server.
# Remove this section when using multiple web servers and ensure you terminate SSL at your load balancer.
#
# Note: If using Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
proxy:
ssl: false
host: 111.111.111.111
# Proxy connects to your container on port 80 by default.
app_port: 3000
# Credentials for your image host.
registry:
# Specify the registry server, if you're not using Docker Hub
# server: registry.digitalocean.com / ghcr.io / ...
username: myuser
# Always use an access token rather than real password (pulled from .kamal/secrets).
password:
- KAMAL_REGISTRY_PASSWORD
# Configure builder setup.
builder:
arch: amd64
# Inject ENV variables into containers (secrets come from .kamal/secrets).
#
# env:
# clear:
# DB_HOST: 192.168.0.2
# secret:
# - RAILS_MASTER_KEY
# Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
# "bin/kamal logs -r job" will tail logs from the first server in the job section.
#
# aliases:
# shell: app exec --interactive --reuse "bash"
# Use a different ssh user than root
#
ssh:
user: myapp
# Use a persistent storage volume.
#
# volumes:
# - "app_storage:/app/storage"
# Bridge fingerprinted assets, like JS and CSS, between versions to avoid
# hitting 404 on in-flight requests. Combines all files from new and old
# version inside the asset_path.
#
asset_path: /home/app/web/public
# Configure rolling deploys by setting a wait time between batches of restarts.
#
# boot:
# limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
# wait: 2
# Use accessory services (secrets come from .kamal/secrets).
#
accessories:
db:
image: postgres:14
host: 111.111.111.111
port: 5432
env:
secret:
- DB_USERNAME
- DB_PASSWORD
- DB_NAME
- DB_HOST
directories:
- data:/var/lib/postgresql/data
redis:
image: "redis:7-alpine"
host: 111.111.111.111
port: 6379
directories:
- data:/data
the kamal deploy log:
i can't find a solution for that, i tried to find some similar issue on kamal repository like this one but i can't make a solution using that. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
Your
Dockerfile
doesn't contain a defaultCMD
. The defaultCMD
for the Ruby docker image is to runirb
.https://hub.docker.com/layers/library/ruby/3.3.6/images/sha256-00e5fb8ebe1724226352ad35ddb9a505531286a5a6add8ab003303e5dcb80706?context=explore
Your
Dockerfile
also doesn't reference your entrypoint script. Kamal doesn't read anything fromdocker-compose.yml
but it does by default build from yourDockerfile
.You'll want something like this in your
Dockerfile
, this is basically the default that ships with Rails now. Yoursetup_app.sh
is pretty similar to the defaultdocker-entrypoint
file.