I’m currently on an Apple Silicon M1 Macbook. I’m wondering if running fly deploy executes the Docker build step locally on my mac. If so, could it be possible that’s why I’m getting the following error?
Here’s the error i’m getting when running fly deploy
This is using your local docker, can you try running fly deploy --remote-only and see if you get better results? Docker on an m1 mac should work fine, so there’s a possibility something else is up.
Oh it would help if I read the error. This seems like a Gemfile.lock problem. You probably have to run this in your app directory to update the bundle lock file:
Add the current platform to the lockfile with bundle lock --add-platform x86_64-linux and try again.
######################
# Stage: Gem Builder
FROM ruby:3.0.1 as Builder
ARG BUNDLE_WITHOUT="development test"
ARG RAILS_ENV="production"
ENV BUNDLE_WITHOUT=${BUNDLE_WITHOUT}
RUN apt-get update && apt-get install -y \
build-essential \
postgresql-client \
git \
npm \
tzdata \
brotli \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install gems
ADD Gemfile* /app/
RUN bundle lock --add-platform x86_64-linux
RUN bundle config --global frozen 1 \
&& bundle install -j4 --retry 3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
###############################
# Stage Final
FROM ruby:3.0.1
RUN apt-get update && apt-get install -y \
file \
postgresql-client \
tzdata \
&& rm -rf /var/lib/apt/lists/*
# Add user
RUN groupadd -r app && useradd -r -g app app
USER app
# Copy app with gems from former build stage
COPY --from=Builder /usr/local/bundle/ /usr/local/bundle/
USER root
RUN mkdir -p /app/tmp/pids && chown -R app:app /app/tmp
ADD --chown=app:app . /app
# Set Rails env
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_ENV production
USER app
WORKDIR /app
# Start up
CMD ["bundle", "exec", "rails", "db:migrate", "&&", "bundle", "exec", "puma", "-C", "config/puma.rb"]
In the logs however, I think some things still aren’t working, but the rails app runs the migrations now.
2021-04-19T07:06:25.062Z 33aa9340 sin [info] Starting instance
2021-04-19T07:06:25.086Z 33aa9340 sin [info] Configuring virtual machine
2021-04-19T07:06:25.087Z 33aa9340 sin [info] Pulling container image
2021-04-19T07:06:32.731Z 33aa9340 sin [info] Unpacking image
2021-04-19T07:06:32.739Z 33aa9340 sin [info] Preparing kernel init
2021-04-19T07:06:33.053Z 33aa9340 sin [info] Configuring firecracker
2021-04-19T07:06:33.323Z 33aa9340 sin [info] Starting virtual machine
2021-04-19T07:06:33.429Z 33aa9340 sin [info] Starting init (commit: 0512da4)...
2021-04-19T07:06:33.447Z 33aa9340 sin [info] Running: `bundle exec rails db:migrate && bundle exec puma -C config/puma.rb` as app
2021-04-19T07:06:33.463Z 33aa9340 sin [info] 2021/04/19 07:06:33 listening on [fdaa:0:21ca:a7b:f0f:33aa:9340:2]:22 (DNS: [fdaa::3]:53)
2021-04-19T07:06:33.671Z 33aa9340 sin [info] `/home/app` is not a directory.
2021-04-19T07:06:33.672Z 33aa9340 sin [info] Bundler will use `/tmp/bundler20210419-503-mi0le5503' as your home directory temporarily.
2021-04-19T07:06:34.625Z 33aa9340 sin [info] invalid option: -C
2021-04-19T07:06:35.459Z 33aa9340 sin [info] Starting clean up.
2021-04-19T07:06:35.459Z 33aa9340 sin [info] Main child exited normally with code: 1
2021-04-19T07:06:38.484Z 33aa9340 sin [info] Starting instance
2021-04-19T07:06:38.509Z 33aa9340 sin [info] Configuring virtual machine
2021-04-19T07:06:38.510Z 33aa9340 sin [info] Pulling container image
2021-04-19T07:06:46.171Z 33aa9340 sin [info] Unpacking image
2021-04-19T07:06:46.178Z 33aa9340 sin [info] Preparing kernel init
2021-04-19T07:06:46.511Z 33aa9340 sin [info] Configuring firecracker
2021-04-19T07:06:46.791Z 33aa9340 sin [info] Starting virtual machine
2021-04-19T07:06:46.903Z 33aa9340 sin [info] Starting init (commit: 0512da4)...
2021-04-19T07:06:46.922Z 33aa9340 sin [info] Running: `bundle exec rails db:migrate && bundle exec puma -C config/puma.rb` as app
2021-04-19T07:06:46.959Z 33aa9340 sin [info] 2021/04/19 07:06:46 listening on [fdaa:0:21ca:a7b:f0f:33aa:9340:2]:22 (DNS: [fdaa::3]:53)
2021-04-19T07:06:47.175Z 33aa9340 sin [info] `/home/app` is not a directory.
2021-04-19T07:06:47.176Z 33aa9340 sin [info] Bundler will use `/tmp/bundler20210419-503-u7uhrc503' as your home directory temporarily.
2021-04-19T07:06:48.142Z 33aa9340 sin [info] invalid option: -C
2021-04-19T07:06:48.933Z 33aa9340 sin [info] Main child exited normally with code: 1
2021-04-19T07:06:48.934Z 33aa9340 sin [info] Starting clean up.
2021-04-19T07:06:58.093Z 33aa9340 sin [info] Health check status changed to 'passing'
Wondering why that’s the case though.
It’s painful to set up Dockerfile to work with Rails Webpacker though haha.
Do release commands run before the release is made live? What are the consequences of a failed release command? Will a rollback to a previous release occur?