Note: this guide expects that your app is using Ruby version 3.3, which is the only version of Ruby supported by Appliku. It's possible to run with a different version of Ruby if you use a custom docker file.

Create New Application in Appliku

image

Copy the Database

In Heroku find the your database under installed add-ons, likely it's called Heroku Postgres. Click into it and determine the version of Postgres, in this example Version 15.6 is used. image

In Appliku create a new database with the same version of Postgres, in this example PostgreSQL 15 will be used. Then in Appliku click into the new database, click the show credentials button and copy the DATABASE_URL. For this article we'll refer to the new Appliku database URL as NEW_DB_URL.

image

Next, go into Heroku and find the old database url by clicking settings from the Heroku Postgres add-on. For this article we'll refer to the Heroku database url as OLD_DB_URL. image

Now we have both database url's we can use the Appliku Postgres Import tool to transfer our data. Fill in the values with the actual database url values and click create database.

image

Add redis (optional)

If you're using heroku-redis click into it from the add-ons and determine the version, in this example the app is using version 6.2.14 image

Back in the Appliku application create another database and select the appropriate version of Redis, in this case Redis 6 will be used. Then click create Database. image

Copy the environment variables

In the Heroku settings for the project find the config vars and copy them into the project settings in Appliku. See images below. image

image

Note: The DATABASE_URL and REDIS_URL should already be set in Appliku. The REDIS_TEMPORARY_URL and REDIS_TLS_URL do not need to be copied over.

Click Save & Deploy, this will save the environment variables but expect the deploy to Fail.

Copy the web process from Heroku to Appliku

In Heroku you can find your processes under resources, depending on you configuration you may have several processes. If you have a Procfile in your project you should copy all the processes from there instead of looking at Heroku. image However, in Appliku you can't specify variables in the command itself, because variable expansion will not happen. So we could either create a shell script with this command and call it like bash we.sh. But, below processes are recommended and should work. web will run the server and release will run migrations

web: bin/rails server
release: bin/rails db:migrate

image

Update Build settings

Now update the build settings in the Appliku application to use Ruby. At this time Appliku only supports Ruby version 3.3 so if you're not using Ruby version 3.3 in your Gemfile you'll need to upgrade to ruby 3.3. Alternatively you can use a custom docker file in Appliku, which if you're using Webpacker and Node.js you will need to do anyway.

Click save at the bottom. image

Install Node.js

If you try to deploy now and see an error that Node.js is not installed, on Heroku you likely used a buildpack to install node. We can use a Custom Docker File and to install Node.

Instead of selecting Ruby 3.3 Rails for the Base Docker Image in Application Settings, select Custom Dockerfile and paste the following.

# syntax = docker/dockerfile:1
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
ARG RUBY_VERSION=3.3.0
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
SHELL ["/bin/bash", "-c"]
# Rails app lives here
WORKDIR /rails
# Set production environment
ENV RAILS_ENV="production" \
    BUNDLE_DEPLOYMENT="1" \
    BUNDLE_PATH="/usr/local/bundle" \
    BUNDLE_WITHOUT="development"
# Throw-away build stage to reduce size of final image
FROM base as build
# Install packages needed to build gems and Node.js and Yarn
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential git libvips pkg-config libpq-dev curl && \
    curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
    apt-get install -y nodejs && \
    curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
    apt-get update && apt-get install -y yarn


# Install application gems
COPY ./code/Gemfile ./code/Gemfile.lock ./
RUN bundle install && \
    rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
    bundle exec bootsnap precompile --gemfile
RUN gem install pg
# Copy application code
COPY ./code .
COPY ./env/ /env/
# Install Node.js dependencies
RUN yarn install
ENV SECRET_KEY_BASE_DUMMY=1
# Precompile bootsnap code for faster boot times
RUN source /env/envs_export.sh && bundle exec bootsnap precompile app/ lib/
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN source /env/envs_export.sh && ./bin/rails assets:precompile
# Final stage for app image
FROM base
# Install packages needed for deployment
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y curl libpq-dev libvips nodejs yarn && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails
# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
    chown -R rails:rails db log storage tmp
USER rails:rails
# Start the server by default, this can be overwritten at runtime

Note: This is the same as the 3.3 docker file except it includes Node and Yarn, if you needed a different Ruby version you can change RUBY_VERSION . Then Save & Deploy.

This time the deploy should work. You can test it on the subdomain provided by Appliku and if everything looks good you can update the Domain in Appliku to point to your custom domain.

Check out https://1manstartup.com/