Browse Source

Make docker-compose actually useful

pull/275/head
baarkerlounger 3 years ago
parent
commit
407c19a83b
  1. 2
      Dockerfile
  2. 33
      Dockerfile_dev
  3. 4
      Gemfile.lock
  4. 4
      config/database.yml
  5. 8
      docker-compose.yml

2
Dockerfile

@ -16,7 +16,7 @@ RUN apk add --no-cache build-base yarn postgresql-dev git
# Install bundler to run bundle exec
# This should be the same version as the Gemfile.lock
RUN gem install bundler:2.2.3 --no-document
RUN gem install bundler:2.3.4 --no-document
# Install gems defined in Gemfile
COPY .ruby-version Gemfile Gemfile.lock /app/

33
Dockerfile_dev

@ -0,0 +1,33 @@
# Build compilation image
FROM ruby:3.0.3-alpine3.14 as builder
# The application runs from /app
WORKDIR /app
# Add the timezone as it's not configured by default in Alpine
RUN apk add --update --no-cache tzdata && cp /usr/share/zoneinfo/Europe/London /etc/localtime && echo "Europe/London" > /etc/timezone
RUN apk add --no-cache build-base yarn postgresql-dev git bash
# Install bundler to run bundle exec
# This should be the same version as the Gemfile.lock
RUN gem install bundler:2.3.4 --no-document
# Install gems defined in Gemfile
COPY .ruby-version Gemfile Gemfile.lock /app/
ARG BUNDLE_FLAGS="--jobs=4 --no-binstubs --no-cache"
RUN bundle install ${BUNDLE_FLAGS}
# Install node packages defined in package.json, including webpack
COPY package.json yarn.lock /app/
RUN yarn install --frozen-lockfile
# Copy all files to /app (except what is defined in .dockerignore)
COPY . /app/
ENV PORT=8080
EXPOSE ${PORT}
CMD RAILS_ENV=${RAILS_ENV} bundle exec rake db:migrate && bundle exec rails s -e ${RAILS_ENV} -p ${PORT} --binding=0.0.0.0

4
Gemfile.lock

@ -8,7 +8,7 @@ GIT
GIT
remote: https://github.com/baarkerlounger/devise.git
revision: ac956cc2a58daa57e071202967a212a1dac08053
revision: 6d0b6b52a9d0e87ae6d9f9acb562169751623078
branch: dluhc-fixes
specs:
devise (4.8.1)
@ -31,7 +31,7 @@ GIT
GIT
remote: https://github.com/tagliala/activeadmin.git
revision: d1492c54e76871d95f3a7ff20e445b48f455d4cb
revision: 920f14393bcf56cea9dc155276d20bcd10f4fa85
branch: feature/railties-7
specs:
activeadmin (2.9.0)

4
config/database.yml

@ -28,8 +28,8 @@ default: &default
development:
<<: *default
database: data_collector_development
host: localhost
database: <%= ENV['DB_DATABASE'] || data_collector_development %>
host: <%= ENV['DB_HOST'] || localhost %>
staging:
<<: *default

8
docker-compose.yml

@ -5,7 +5,7 @@ volumes:
services:
db:
image: postgres:13.3-alpine
image: postgres:13.5-alpine
restart: always
# To preserve data between runs of docker-compose, we mount a folder from the host machine.
volumes:
@ -20,9 +20,7 @@ services:
app:
build:
context: .
dockerfile: ./Dockerfile
args:
GIT_COMMIT_SHA: DOCKER_COMPOSE_GIT_COMMIT_SHA
dockerfile: ./Dockerfile_dev
ports:
- 8080:8080
depends_on:
@ -32,7 +30,7 @@ services:
- DB_DATABASE=data_collector
- DB_USERNAME=postgres
- DB_PASSWORD=password
- RAILS_ENV=production
- RAILS_ENV=development
- RAILS_SERVE_STATIC_FILES=true
- RAILS_LOG_TO_STDOUT=true
- SECRET_KEY_BASE=abcd1234

Loading…
Cancel
Save