diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2d50acbe --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/compose.yml b/compose.yml new file mode 100644 index 00000000..cd2de263 --- /dev/null +++ b/compose.yml @@ -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 diff --git a/config/database.yml b/config/database.yml index 9614018d..7450803d 100755 --- a/config/database.yml +++ b/config/database.yml @@ -9,8 +9,9 @@ # 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 @@ -18,10 +19,14 @@ development: # 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 diff --git a/tracker b/tracker new file mode 100755 index 00000000..22c6f110 --- /dev/null +++ b/tracker @@ -0,0 +1,8 @@ +#!/bin/bash + +if [[ $1 == rails && $2 == s ]]; then + docker compose up + docker compose down +else + docker compose exec web $@ +fi