Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
/public/system/attachments/*
/public/system/thumbnails/*
/public/ckeditor_assets
/public/assets/

# Ignore Byebug command history file.
.byebug_history
Expand Down
80 changes: 49 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
FROM ruby:2.7.8-buster
FROM ruby:3.3.8-slim AS base

# Set working directory
WORKDIR /app

# Set environment variables
ENV RAILS_ENV=production \
RACK_ENV=production \
BUNDLE_PATH=/gems \
BUNDLE_WITHOUT="development test" \
BUNDLE_BIN=/gems/bin \
PATH="/gems/bin:$PATH"

# Install bundler
RUN gem install bundler -v 2.5.22


FROM base AS assets

# Install basic Linux packages
RUN apt-get update -qq && apt-get install -y \
build-essential \
libpq-dev \
nodejs \
yarn \
git \
curl \
imagemagick \
libvips \
tzdata \
Expand All @@ -16,22 +30,7 @@ RUN apt-get update -qq && apt-get install -y \
libffi-dev \
libreadline-dev \
libssl-dev \
zlib1g-dev \
libsqlite3-dev \
sqlite3

# Set working directory
WORKDIR /app

# Set environment variables
ENV RAILS_ENV=production \
RACK_ENV=production \
BUNDLE_PATH=/gems \
BUNDLE_BIN=/gems/bin \
PATH="/gems/bin:$PATH"

# Install bundler
RUN gem install bundler -v 2.4.12
zlib1g-dev

# Copy app code and install dependencies
COPY . .
Expand All @@ -41,21 +40,40 @@ RUN bundle install --without development test
# These envs are used in the rails application. While they are entirely
# unrelated to the docker build process, they are required for the app to run.
# Without these build args the asset precompilation will fail.
ARG SECRET_KEY_BASE
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_REGION
ARG AWS_S3_BUCKET
ARG SMTP_USERNAME
ARG SMTP_PASSWORD
ARG SMTP_SERVER
ARG SMTP_PORT

# Precompile assets (if applicable)
RUN bundle exec rake assets:precompile
RUN SECRET_KEY_BASE=1 bundle exec rake assets:precompile


FROM base AS server

RUN apt-get update -qq && apt-get install --no-install-recommends -y \
imagemagick \
libvips \
tzdata \
libxml2 \
libxslt1.1 \
libffi8 \
libreadline8 \
libssl3 \
zlib1g \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*




# Set working directory
WORKDIR /app

COPY --from=assets /gems /gems
COPY --from=assets /app/public/assets /app/public/assets

# Copy app code and install dependencies
COPY . .

# Expose port (default Rails)
EXPOSE 3000

# Start the server (customize to your app server if needed)
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
4 changes: 4 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
*= require_self
*= require awbw
*/
11 changes: 0 additions & 11 deletions bin/yarn

This file was deleted.

3 changes: 3 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ test:
<<: *base
pool: 5
database: awbw_test

production:
<<: *base
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
# number of complex assets.
config.assets.debug = true

config.assets.unknown_asset_fallback = false

# Suppress logger output for asset requests.
config.assets.quiet = true

Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.public_file_server.enabled = true

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ services:
stdin_open: true
restart: unless-stopped


prod:
profiles:
- production
build:
context: .
dockerfile: Dockerfile
target: server
depends_on:
- database
environment:
DATABASE_URL: trilogy://root@database:3306/awbw_development
RAILS_LOG_TO_STDOUT: "true"
SECRET_KEY_BASE: "foobar"
ports:
- 3030:3000



volumes:
mysql-data: