mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-21 21:40:48 +02:00
Replace the version-specific Dockerfiles with one staged Dockerfile
This commit is contained in:
parent
5940fe10a6
commit
ff5adc5696
19 changed files with 75 additions and 271 deletions
|
@ -3,9 +3,7 @@ config/database.yml
|
|||
config/site.yml
|
||||
coverage
|
||||
db/*.sqlite3
|
||||
doc
|
||||
features
|
||||
log
|
||||
public/assets
|
||||
test
|
||||
tmp
|
||||
|
|
1
.github/workflows/build-latest.yml
vendored
1
.github/workflows/build-latest.yml
vendored
|
@ -35,6 +35,7 @@ jobs:
|
|||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
target: production
|
||||
push: true
|
||||
tags: |
|
||||
tracksapp/tracks:latest
|
||||
|
|
1
.github/workflows/build-release.yml
vendored
1
.github/workflows/build-release.yml
vendored
|
@ -35,6 +35,7 @@ jobs:
|
|||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
target: production
|
||||
push: true
|
||||
tags: |
|
||||
tracksapp/tracks:${{ github.event.release.name }}
|
||||
|
|
42
Dockerfile
42
Dockerfile
|
@ -1,20 +1,13 @@
|
|||
FROM ruby:3.3
|
||||
|
||||
# throw errors if Gemfile has been modified since Gemfile.lock
|
||||
RUN bundle config --global frozen 1
|
||||
RUN bundle config set --local without test development stripe
|
||||
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
|
||||
|
||||
|
@ -39,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
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
FROM ruby:3.0
|
||||
|
||||
# throw errors if Gemfile has been modified since Gemfile.lock
|
||||
RUN bundle config --global frozen 1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN touch /etc/app-env
|
||||
|
||||
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
|
||||
|
||||
COPY Gemfile* /app/
|
||||
RUN gem install bundler
|
||||
RUN bundle install --jobs 4
|
||||
|
||||
RUN mkdir /app/log
|
||||
|
||||
COPY . /app/
|
||||
COPY config/database.docker.yml /app/config/database.yml
|
||||
COPY config/site.docker.yml /app/config/site.yml
|
||||
|
||||
RUN RAILS_ENV=production bundle exec rake assets:precompile
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["rails", "server", "-b", "0.0.0.0"]
|
|
@ -1,30 +0,0 @@
|
|||
FROM ruby:3.1
|
||||
|
||||
# throw errors if Gemfile has been modified since Gemfile.lock
|
||||
RUN bundle config --global frozen 1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN touch /etc/app-env
|
||||
|
||||
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
|
||||
|
||||
COPY Gemfile* /app/
|
||||
RUN gem install bundler
|
||||
RUN bundle install --jobs 4
|
||||
|
||||
RUN mkdir /app/log
|
||||
|
||||
COPY . /app/
|
||||
COPY config/database.docker.yml /app/config/database.yml
|
||||
COPY config/site.docker.yml /app/config/site.yml
|
||||
|
||||
RUN RAILS_ENV=production bundle exec rake assets:precompile
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["rails", "server", "-b", "0.0.0.0"]
|
|
@ -1,30 +0,0 @@
|
|||
FROM ruby:3.2
|
||||
|
||||
# throw errors if Gemfile has been modified since Gemfile.lock
|
||||
RUN bundle config --global frozen 1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN touch /etc/app-env
|
||||
|
||||
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
|
||||
|
||||
COPY Gemfile* /app/
|
||||
RUN gem install bundler
|
||||
RUN bundle install --jobs 4
|
||||
|
||||
RUN mkdir /app/log
|
||||
|
||||
COPY . /app/
|
||||
COPY config/database.docker.yml /app/config/database.yml
|
||||
COPY config/site.docker.yml /app/config/site.yml
|
||||
|
||||
RUN RAILS_ENV=production bundle exec rake assets:precompile
|
||||
|
||||
ENTRYPOINT ["/app/docker-entrypoint.sh"]
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["rails", "server", "-b", "0.0.0.0"]
|
30
Gemfile
30
Gemfile
|
@ -28,20 +28,17 @@ gem 'sanitize', '~> 6.1'
|
|||
gem 'tracks-chartjs-ror'
|
||||
gem 'will_paginate'
|
||||
|
||||
group :layout do
|
||||
gem 'listen'
|
||||
gem 'tolk', '~> 5.0.1'
|
||||
end
|
||||
|
||||
# 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'
|
||||
|
||||
|
@ -52,22 +49,25 @@ group :development do
|
|||
gem 'i18n-tasks', '~> 1.0.14'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
group :development, :test, :optional => true do
|
||||
gem 'byebug'
|
||||
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
|
||||
|
||||
gem 'stripe', "~> 5.24.0", group: :stripe
|
||||
group :stripe, :optional => true do
|
||||
gem 'stripe', "~> 5.24.0"
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile-3.0
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: $DATABASE_NAME
|
||||
DATABASE_USERNAME: root
|
||||
DATABASE_PASSWORD_EMPTY: 1
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
db-data:
|
|
@ -1,29 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile-3.1
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: $DATABASE_NAME
|
||||
DATABASE_USERNAME: root
|
||||
DATABASE_PASSWORD_EMPTY: 1
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
db-data:
|
|
@ -1,29 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
||||
MYSQL_DATABASE: ${TRACKS_DB:-tracks}
|
||||
volumes:
|
||||
- db-data:/var/lib/mysql
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile-3.2
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: $DATABASE_NAME
|
||||
DATABASE_USERNAME: root
|
||||
DATABASE_PASSWORD_EMPTY: 1
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
db-data:
|
|
@ -1,32 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
db:
|
||||
image: postgres:13
|
||||
environment:
|
||||
POSTGRES_DB: ${DATABASE_NAME:-tracks}
|
||||
POSTGRES_PASSWORD: password
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: $DATABASE_NAME
|
||||
DATABASE_USERNAME: postgres
|
||||
DATABASE_PASSWORD: password
|
||||
DATABASE_TYPE: postgresql
|
||||
DATABASE_ENCODING: unicode
|
||||
DATABASE_PORT: 5432
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
db-data:
|
|
@ -1,17 +0,0 @@
|
|||
version: '3'
|
||||
services:
|
||||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: "/app/db.sqlite"
|
||||
DATABASE_TYPE: sqlite3
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
|
@ -10,7 +10,9 @@ services:
|
|||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile
|
||||
target: test
|
||||
args:
|
||||
RUBY_VERSION: ${RUBY_VERSION}
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
|
@ -10,7 +10,9 @@ services:
|
|||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile-3.0
|
||||
target: test
|
||||
args:
|
||||
RUBY_VERSION: ${RUBY_VERSION}
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
|
@ -3,15 +3,19 @@ services:
|
|||
web:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: Dockerfile-3.0
|
||||
target: test
|
||||
args:
|
||||
RUBY_VERSION: ${RUBY_VERSION}
|
||||
environment:
|
||||
# These are set in script/ci-build, so we need to pass-thru them.
|
||||
RAILS_ENV: $RAILS_ENV
|
||||
DATABASE_NAME: "/app/db.sqlite"
|
||||
DATABASE_NAME: "/app/db/db.sqlite"
|
||||
DATABASE_TYPE: sqlite3
|
||||
volumes:
|
||||
- ${VOLUME:-..}:/app:Z
|
||||
- ${VOLUME:-sqlite}:/app/db:Z
|
||||
- ${VOLUME:-..}/config/database.docker.yml:/app/config/database.yml:Z
|
||||
- ${VOLUME:-..}/config/site.docker.yml:/app/config/site.yml:Z
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
sqlite: {}
|
Loading…
Add table
Add a link
Reference in a new issue