Skip to content

Commit

Permalink
Dockerize app (#102)
Browse files Browse the repository at this point in the history
* Dockerize app

* Specify platform

* Specify database host
adamniedzielski authored Jun 14, 2024
1 parent 6c8cb9d commit 48da0e3
Showing 6 changed files with 58 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -24,3 +24,4 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
.env.dev
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@ AllCops:
Exclude:
- "bin/**/*"
- "db/schema.rb"

- "vendor/**/*"
- "tmp/**/*"
Style/StringLiterals:
EnforcedStyle: double_quotes
Style/Documentation:
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ruby:3.0.2-alpine AS dev
RUN apk add build-base postgresql-dev tzdata bash
WORKDIR /neue_wohnung
ENV BUNDLE_PATH=/bundle \
BUNDLE_BIN=/bundle/bin \
GEM_HOME=/bundle
ENV PATH="${BUNDLE_BIN}:${PATH}"
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
build:
docker-compose build

install:
docker-compose run --rm web bundle install

dbsetup:
docker-compose run --rm web bundle exec rails db:setup

server:
docker-compose run --rm --service-ports web

console:
docker-compose run --rm web bundle exec rails console

rubocop:
docker-compose run --rm web bundle exec rubocop

bash:
docker-compose run --rm web bash
3 changes: 3 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ default: &default
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: <%= ENV['DATABASE_HOST'] %>
username: postgres
password: db_password

development:
<<: *default
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.9"
services:
web:
platform: linux/x86_64
build:
context: .
target: dev
env_file:
- .env.dev
stdin_open: true
tty: true
command: bundle exec rails server --binding 0.0.0.0
volumes:
- ".:/neue_wohnung"
- bundle:/bundle
ports:
- "3000:3000"
depends_on:
- db
db:
image: "healthcheck/postgres:alpine"
environment:
POSTGRES_PASSWORD: db_password
volumes:
bundle:

0 comments on commit 48da0e3

Please sign in to comment.