Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switches to a docker version for local development. Removes SQLITE uses #579

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM ruby:3.0.7

# install RVM
RUN apt-get update && apt-get install -y --no-install-recommends gnupg2
RUN gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \curl -sSL https://get.rvm.io | bash -s stable && /bin/bash

# install ruby
ENV RUBY_VERSION=3.0.7
RUN /bin/bash -l -c "rvm install $RUBY_VERSION && rvm --default use $RUBY_VERSION"

# install nodejs
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash && apt-get install -y --no-install-recommends nodejs

# Create working directory
WORKDIR /build

# Install chromium
RUN apt-get update && apt-get install -y --no-install-recommends chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

COPY . /build/

RUN gem install bundler
# RUN rbenv rehash
RUN RAILS_ENV=development bundle install
# RUN rbenv rehash
RUN npm install -g yarn
RUN yarn install
RUN RAILS_ENV=development rails assets:precompile

# Expose port 3000 to the outside world
EXPOSE 3000

# The command to run the app
CMD ["bash", "-c", "rm -f tmp/pids/server.pid && rails server -b 0.0.0.0"]

# To build this image, run `docker-compose build` in the terminal
29 changes: 29 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
services:
mysql:
image: mysql:9.2.0
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: development
MYSQL_USER: tracker
MYSQL_PASSWORD: password
ports:
- "3306:3306"
volumes:
- ./tmp/db:/var/lib/mysql
web:
build:
context: .
dockerfile: Dockerfile
command: bash -c "rm -f tmp/pids/server.pid && rails server -b 0.0.0.0"
develop:
watch:
- action: sync
path: ./app
target: ./build/app
environment:
RAILS_ENV: development
DATABASE_URL: mysql2://tracker:password@mysql/development
ports:
- "3000:3000"
depends_on:
- mysql
15 changes: 10 additions & 5 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,24 @@
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: sqlite3
database: db/development.sqlite3
adapter: mysql2
encoding: utf8mb4
collation: utf8mb4_bin
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
adapter: mysql2
encoding: utf8
database: abtt_test
pool: 5
timeout: 5000
username: deploy-abtech-tracker
password:
socket: /var/run/mysqld/mysqld.sock
collation: utf8_unicode_ci

staging:
adapter: mysql2
Expand Down
8 changes: 8 additions & 0 deletions tracker
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [[ $1 == rails && $2 == s ]]; then
docker compose up
docker compose down
else
docker compose exec web $@
fi