Once, I regretted 2$ for a mobile app, and I wrote a similar, but PWA app from scratch. My daughter challenged me, and said “It’s not an app if it’s not in App Store”. It worked, I rewrite some parts with ionic, pay for Apple and Google developer account (99$ and 20$ if I remember correctly), learned how mobile app deployment works and finished with exactly the same app (as a PWA, the app for 2$ was much better)

Ok, but whole story is about delivery, you can do whatever you want and until you deliver it doesn’t count. Same story with commercial projects. Done is better than perfect, why MVP is better than MLP, I can write a lot about this topic.

But today I want to deploy my hello world app. I have a crazy stack so I thought of crazy infrastructure, but maybe in the future. Right now I want something super simple, this is why I decided to go PaaS. After Heroku dropped their free plans, fly.io is my first choice.

Fly.io has powerfull CLI so whole setup we can do from terminal. Also they have good tutorials how to run apps.

The whole setup basically generates dockerfile for us. And we also can use this file locally.

ARG RUBY_VERSION=3.2.2
FROM ruby:$RUBY_VERSION-slim as base

# Rack app lives here
WORKDIR /app

# Update gems and bundler
RUN gem update --system --no-document && \
    gem install -N bundler


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build gems
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential

# Install application gems
COPY Gemfile* .
RUN bundle install


# Final stage for app image
FROM base

# Run and own the application files as a non-root user for security
RUN useradd ruby --home /app --shell /bin/bash
USER ruby:ruby

# Copy built artifacts: gems, application
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build --chown=ruby:ruby /app /app

# Copy application code
COPY --chown=ruby:ruby . .

# Start the server
EXPOSE 8080
CMD ["bundle", "exec", "rackup", "--host", "0.0.0.0", "--port", "8080"]

I don’t have any envs, any secretes right now, so I don’t need to configure anything. Just simple fly deploy.

App works on url https://summer-flower-5307.fly.dev/ (I’m going to connect domain in future). Code is available on github. Fly.io provides simple metrics and monitoring which I will try to replace with something better in the future.