Skip to content

Commit

Permalink
Merge pull request #3033 from TracksApp/stripe
Browse files Browse the repository at this point in the history
Add Stripe as an optional package and move to a single staged Dockerfile
  • Loading branch information
ZeiP committed Jul 18, 2024
2 parents 11ef1b6 + ff5adc5 commit 75a88f2
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 269 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ config/database.yml
config/site.yml
coverage
db/*.sqlite3
doc
features
log
public/assets
test
tmp
1 change: 1 addition & 0 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
target: production
push: true
tags: |
tracksapp/tracks:latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
target: production
push: true
tags: |
tracksapp/tracks:${{ github.event.release.name }}
Expand Down
41 changes: 29 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
FROM ruby:3.3

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
ARG RUBY_VERSION=3.3
FROM ruby:${RUBY_VERSION} AS base

WORKDIR /app

RUN touch /etc/app-env

COPY Gemfile* /app/
RUN gem install bundler
RUN bundle install --jobs 4

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update && apt-get install -y yarn netcat-openbsd
RUN gem install bundler

RUN mkdir /app/log

Expand All @@ -38,10 +32,33 @@ COPY db /app/db/

COPY .git /app/.git

RUN RAILS_ENV=production bundle exec rake assets:precompile
COPY Gemfile* /app/

ENTRYPOINT ["/app/docker-entrypoint.sh"]

EXPOSE 3000

CMD ["./bin/rails", "server", "-b", "0.0.0.0"]

FROM base AS precompile
RUN bundle config set with assets
RUN bundle config set deployment true
RUN bundle install --jobs 4
RUN RAILS_GROUPS=assets bundle exec rake assets:precompile

# Build the environment-specific stuff
FROM base AS production
RUN bundle config --global frozen 1
RUN bundle install --jobs 4
COPY --from=precompile /app/public/assets /app/public/assets

FROM base AS test
COPY test /app/test/
# For testing the API client
COPY doc /app/doc/
RUN bundle config set with development test assets
RUN bundle config --global frozen 1
RUN bundle install --jobs 4
RUN RAILS_GROUPS=assets bundle exec rake assets:precompile

FROM base AS development
RUN bundle config set with development test
RUN bundle install --jobs 4
30 changes: 0 additions & 30 deletions Dockerfile-3.0

This file was deleted.

30 changes: 0 additions & 30 deletions Dockerfile-3.1

This file was deleted.

30 changes: 0 additions & 30 deletions Dockerfile-3.2

This file was deleted.

29 changes: 16 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,46 @@ gem 'sanitize', '~> 6.1'
gem 'tracks-chartjs-ror'
gem 'will_paginate'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'mini_racer', group: :therubyracer

# Use --without <group> argument to skip unnecessary drivers
gem 'sqlite3', group: :sqlite
gem 'mysql2', '~> 0.5.6', group: :mysql
gem 'pg', '~> 1.5.6', group: :postgresql

group :development do
group :assets, :optional => true do
gem 'listen'
gem 'tolk', '~> 5.0.1'
end

group :development, :optional => true do
gem 'spring', '~> 4'
gem 'yard'

gem 'tolk', '~> 5.0.1'

gem 'bullet'
gem 'rack-mini-profiler'
gem 'solargraph'

gem 'i18n-tasks', '~> 1.0.14'
end

group :development, :test do
group :development, :test, :optional => true do
gem 'byebug'
gem 'listen'
gem 'rubocop', '~> 1.65', require: false
gem 'rubocop', '~> 1.65'
gem 'mini_racer'
end

group :test do

group :test, :optional => true do
# get test coverage info on codeclimate
gem 'codeclimate-test-reporter', '1.0.9', group: :test, require: nil
gem 'codeclimate-test-reporter', '1.0.9'
gem 'database_cleaner', '~> 1'
gem 'factory_bot_rails'
gem 'minitest-stub-const'
gem 'mocha', :require => false
gem 'mocha'
gem 'rails-controller-testing'
gem 'rails-dom-testing', '~> 2.2.0'
gem 'rspec-expectations'
gem 'simplecov'
end

group :stripe, :optional => true do
gem 'stripe', "~> 5.24.0"
end
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ GEM
tilt (~> 2.0)
yard (~> 0.9, >= 0.9.24)
spring (4.2.1)
sprockets (4.2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
Expand All @@ -313,6 +313,7 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.6.9)
mini_portile2 (~> 2.8.0)
stripe (5.24.0)
strscan (3.1.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand Down Expand Up @@ -383,6 +384,7 @@ DEPENDENCIES
solargraph
spring (~> 4)
sqlite3
stripe (~> 5.24.0)
tolk (~> 5.0.1)
tracks-chartjs-ror
uglifier (>= 1.3.0)
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ services:
volumes:
- db-data:/var/lib/mysql
web:
build: .
build:
context: .
target: production # can also be development or test
environment:
# These are set in script/ci-build, so we need to pass-thru them.
RAILS_ENV: $RAILS_ENV
Expand Down
4 changes: 3 additions & 1 deletion script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -e

docker_compose="docker-compose --file test-envs/docker-compose-$1-$2.yml"
export RUBY_VERSION=$1

docker_compose="docker-compose --file test-envs/docker-compose-$2.yml"

function cleanup() {
$docker_compose down
Expand Down
18 changes: 10 additions & 8 deletions script/poll-for-db
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

echo "==> Polling DB…"

appdir=$(cd $(dirname "$0")/.. && pwd)
[ -f /etc/app-env ] || exec "$appdir/script/docker-environment" $0 $@
if [ "$DATABASE_TYPE" == "mysql" ]; then
appdir=$(cd $(dirname "$0")/.. && pwd)
[ -f /etc/app-env ] || exec "$appdir/script/docker-environment" $0 $@

for i in {1..60}; do
nc -z -w5 db 3306 && exit
sleep 1
done
for i in {1..60}; do
nc -z -w5 db 3306 && exit
sleep 1
done

echo "Unable to reach database!"
exit 1
echo "Unable to reach database!"
exit 1
fi
29 changes: 0 additions & 29 deletions test-envs/docker-compose-3.0-mysql.yml

This file was deleted.

29 changes: 0 additions & 29 deletions test-envs/docker-compose-3.1-mysql.yml

This file was deleted.

29 changes: 0 additions & 29 deletions test-envs/docker-compose-3.2-mysql.yml

This file was deleted.

Loading

0 comments on commit 75a88f2

Please sign in to comment.