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 # Install bundler to run bundle exec
# This should be the same version as the Gemfile.lock # 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 # Install gems defined in Gemfile
COPY .ruby-version Gemfile Gemfile.lock /app/ 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 GIT
remote: https://github.com/baarkerlounger/devise.git remote: https://github.com/baarkerlounger/devise.git
revision: ac956cc2a58daa57e071202967a212a1dac08053 revision: 6d0b6b52a9d0e87ae6d9f9acb562169751623078
branch: dluhc-fixes branch: dluhc-fixes
specs: specs:
devise (4.8.1) devise (4.8.1)
@ -31,7 +31,7 @@ GIT
GIT GIT
remote: https://github.com/tagliala/activeadmin.git remote: https://github.com/tagliala/activeadmin.git
revision: d1492c54e76871d95f3a7ff20e445b48f455d4cb revision: 920f14393bcf56cea9dc155276d20bcd10f4fa85
branch: feature/railties-7 branch: feature/railties-7
specs: specs:
activeadmin (2.9.0) activeadmin (2.9.0)

4
config/database.yml

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

8
docker-compose.yml

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

Loading…
Cancel
Save