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

Add db to webstie #3779

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ clean:
changelog:
docker compose run web bundle exec github_changelog_generator

db:
docker compose up -d db

time-to-live ?= 3h
review_cluster = ${shell ./playbook-website/bin/deployer ./playbook-website/bin/cluster_for_review_stack pr$(pr)}

Expand Down
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,48 @@ services:
- bundle:/usr/local/bundle
ports:
- "8089:3000"
db:
platform: linux/x86_64
image: percona:8.0.27-18@sha256:f649b06357456689c24601fe919d585dce5b289c623bb547f84acc458c34c0d0
init: true
ports:
- "3306:3306" # Map the host port 3306 to the container port 3306
environment:
MYSQL_ROOT_HOST: "%"
MYSQL_ROOT_PASSWORD: password
healthcheck:
test: ["CMD", "mysql", "-u", "root", "-ppassword", "-e", "SHOW DATABASES;"]
interval: 5s
timeout: 2s
retries: 5
start_period: 20s
networks:
- main
redis:
image: redis:7.4.0-alpine@sha256:c35af3bbcef51a62c8bae5a9a563c6f1b60d7ebaea4cb5a3ccbcc157580ae098
healthcheck:
test: ["CMD", "redis-cli", "PING"]
interval: 5s
timeout: 2s
retries: 5
start_period: 20s
ports:
- 6379
networks:
- main
influxdb:
image: influxdb:2.7.10@sha256:aac51f94d98041e591aa4a5f36294080dd7987c1033ff115febfab98adcda61d
container_name: influxdb
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: passwordpasswordpassword
DOCKER_INFLUXDB_INIT_ORG: web
DOCKER_INFLUXDB_INIT_BUCKET: app_data
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: influxdbwebtoken
ports:
- 8086:8086
networks:
- main
networks:
main:
1 change: 1 addition & 0 deletions playbook-website/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ gem "bootsnap", ">= 1.1.0", require: false
# livenessProbe and readinessProbe. See: https://github.com/powerhome/playbook/blob/master/playbook/config/deploy/templates/deployment.yaml.erb
gem "health_check"

gem "mysql2", "0.5.6"
gem "redcarpet", "~> 3.6"
gem 'front_matter_parser', "~> 1.0.1"
gem "rouge", "~> 3.15"
Expand Down
2 changes: 2 additions & 0 deletions playbook-website/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ GEM
mini_mime (1.1.5)
minitest (5.25.1)
msgpack (1.7.2)
mysql2 (0.5.6)
net-imap (0.4.15)
date
net-protocol
Expand Down Expand Up @@ -332,6 +333,7 @@ DEPENDENCIES
front_matter_parser (~> 1.0.1)
health_check
listen
mysql2 (= 0.5.6)
playbook_ui!
psych (< 4)
puma (~> 6.3)
Expand Down
5 changes: 5 additions & 0 deletions playbook-website/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
end
2 changes: 1 addition & 1 deletion playbook-website/bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
21 changes: 13 additions & 8 deletions playbook-website/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "fileutils"

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
APP_ROOT = File.expand_path("..", __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
Expand All @@ -13,16 +13,21 @@ FileUtils.chdir APP_ROOT do
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts "== Installing dependencies =="
system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")

# Install JavaScript dependencies
system! 'bin/yarn'
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
# end

puts "\n== Preparing database =="
system! "bin/rails db:prepare"

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'
system! "bin/rails log:clear tmp:clear"

puts "\n== Restarting application server =="
system! 'bin/rails restart'
system! "bin/rails restart"
end
2 changes: 1 addition & 1 deletion playbook-website/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
Expand Down
20 changes: 20 additions & 0 deletions playbook-website/config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: password
host: 127.0.0.1
port: 3306

development:
<<: *default
database: playbook_website_dev

test:
<<: *default
database: playbook_website_test

production:
<<: *default
database: playbook_website_prod
16 changes: 16 additions & 0 deletions playbook-website/db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 0) do
end
Loading