Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions .dockerignore

This file was deleted.

18 changes: 1 addition & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,4 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global

# Ignore bundler config
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore application configuration
/config/application.yml

/app/assets/builds/*
!/app/assets/builds/.keep

/node_modules
/buildlight
1 change: 0 additions & 1 deletion .node-version

This file was deleted.

2 changes: 0 additions & 2 deletions .rspec

This file was deleted.

1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

3 changes: 0 additions & 3 deletions .standard.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

99 changes: 9 additions & 90 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,96 +1,15 @@
# syntax=docker/dockerfile:1
# check=error=true
FROM golang:1 AS builder

# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.4.4
FROM ruby:$RUBY_VERSION-alpine AS base
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

LABEL fly_launch_runtime="rails"

# Rails app lives here
WORKDIR /rails

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

# Install base packages
RUN apk add --no-cache curl jemalloc postgresql-client tzdata

# Set production environment
ENV BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development:test" \
RAILS_ENV="production"


# Throw-away build stages to reduce size of final image
FROM base AS prebuild

# Install packages needed to build gems and node modules
RUN apk add --no-cache build-base git gyp libpq-dev pkgconfig python3 yaml-dev


FROM prebuild AS node

# Install Node.js
ARG NODE_VERSION=22.4.0
ENV PATH=/usr/local/node/bin:$PATH
RUN curl -sL https://unofficial-builds.nodejs.org/download/release/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64-musl.tar.gz | tar xz -C /tmp/ && \
mkdir /usr/local/node && \
cp -rp /tmp/node-v${NODE_VERSION}-linux-x64-musl/* /usr/local/node/ && \
rm -rf /tmp/node-v${NODE_VERSION}-linux-x64-musl

# Install node modules
COPY package.json ./
RUN npm install


FROM prebuild AS build

# Install application gems
COPY Gemfile Gemfile.lock .ruby-version ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile --gemfile

# Copy node modules
COPY --from=node /rails/node_modules /rails/node_modules
COPY --from=node /usr/local/node /usr/local/node
ENV PATH=/usr/local/node/bin:$PATH

# Copy application code
COPY . .
RUN CGO_ENABLED=0 go build -tags production -o buildlight ./cmd/buildlight

# Precompile bootsnap code for faster boot times
RUN bundle exec bootsnap precompile app/ lib/

# Adjust binfiles to set current working directory
RUN grep -l '#!/usr/bin/env ruby' /rails/bin/* | xargs sed -i '/^#!/aDir.chdir File.expand_path("..", __dir__)'

# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile


# Final stage for app image
FROM base

# Install packages needed for deployment
RUN apk add --no-cache gzip libpq

# Copy built artifacts: gems, application
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails /rails

# Run and own only the runtime files as a non-root user for security
RUN addgroup --system --gid 1000 rails && \
adduser --system rails --uid 1000 --ingroup rails --home /home/rails --shell /bin/sh rails && \
chown -R 1000:1000 db log tmp
USER 1000:1000
FROM debian:stable-slim

# Entrypoint sets up the container.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
COPY --from=builder /app/buildlight /usr/local/bin/buildlight

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]
EXPOSE 8080
CMD ["buildlight"]
32 changes: 0 additions & 32 deletions Gemfile

This file was deleted.

Loading
Loading