Adds optional support for Docker/Compose (#296)
* Adds optional support for Docker/Compose * Upgrades Dockerfile to use a multi-stage build * Gets rest of stack running in Docker * Renames queue to jobs, uses jobs namespace command * Reverts file * Adds webpacker * Fixes yarn check issue * Adds Database URL default connection string * Remove daemons gem * Update huskyhook config * Update seed.rb * Create .dockerignore * Increase RackTimeout's config * Simplify Docker config * Update README * Remove postgres url default * Change docker entry point to 3000 * Remove duped integrity setting
This commit is contained in:
parent
8c70c95cea
commit
cfda390845
11 changed files with 85 additions and 8 deletions
5
.dockerignore
Normal file
5
.dockerignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
.dockerignore
|
||||
.git
|
||||
logs/
|
||||
tmp/
|
||||
node_modules/
|
||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
FROM starefossen/ruby-node:2-8-stretch
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY Gemfile Gemfile.lock yarn.lock ./
|
||||
|
||||
RUN yarn install && yarn check --integrity
|
||||
|
||||
ENV RAILS_ENV development
|
||||
|
||||
ENV YARN_INTEGRITY_ENABLED "false"
|
||||
|
||||
RUN bundle install --jobs 20 --retry 5
|
||||
|
||||
ENTRYPOINT ["bundle", "exec"]
|
||||
|
||||
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "3000"]
|
||||
4
Envfile
4
Envfile
|
|
@ -15,8 +15,8 @@ variable :APP_PROTOCOL, :String, default: "http://"
|
|||
variable :DEVTO_USER_ID, :Integer, default: 1
|
||||
|
||||
# Service timeout length
|
||||
variable :RACK_TIMEOUT_WAIT_TIMEOUT, :Integer, default: 100
|
||||
variable :RACK_TIMEOUT_SERVICE_TIMEOUT, :Integer, default: 100
|
||||
variable :RACK_TIMEOUT_WAIT_TIMEOUT, :Integer, default: 100000
|
||||
variable :RACK_TIMEOUT_SERVICE_TIMEOUT, :Integer, default: 100000
|
||||
|
||||
# Production related config that can be ignored
|
||||
variable :DEPLOYMENT_SIGNATURE, :String, default: "Optional"
|
||||
|
|
|
|||
4
Makefile
Normal file
4
Makefile
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.PHONY: run
|
||||
|
||||
run:
|
||||
docker-compose build && docker-compose run --rm web rails db:setup
|
||||
14
README.md
14
README.md
|
|
@ -151,7 +151,7 @@ This section provides a high-level requirement & quick start guide. For detailed
|
|||
- [Yarn](https://yarnpkg.com/): please refer to their [installation guide](https://yarnpkg.com/en/docs/install).
|
||||
- [PostgreSQL](https://www.postgresql.org/) 9.4 or higher.
|
||||
|
||||
### Installation
|
||||
### Standard Installation
|
||||
|
||||
0. Make sure all the prerequisites are installed.
|
||||
1. Fork dev.to repository, ie. https://github.com/thepracticaldev/dev.to/fork
|
||||
|
|
@ -177,6 +177,18 @@ This section provides a high-level requirement & quick start guide. For detailed
|
|||
|
||||
[View Full Installation Documentation](https://docs.dev.to/installation/)
|
||||
|
||||
### Docker Installation (BETA)
|
||||
|
||||
Our docker implementation is incomplete and may not work smoothly. Please kindly report any issues and any contribution is welcomed!
|
||||
|
||||
1. Install `docker` and `docker-compose`
|
||||
1. `git clone git@github.com:thepracticaldev/dev.to.git`
|
||||
1. Set environment variables above as described in the "Basic Installation"
|
||||
1. run `docker-compose build`
|
||||
1. run `docker-compose run web rails db:setup`
|
||||
1. run `docker-compose up`
|
||||
1. That's it! Navigate to `localhost:3000`
|
||||
|
||||
#### Starting the application
|
||||
|
||||
We're mostly a Rails app, with a bit of Webpack sprinkled in. **For most cases, simply running `bin/rails server` will do.** If you're working with Webpack though, you'll need to run the following:
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ default: &default
|
|||
checkout_timeout: 2
|
||||
variables:
|
||||
statement_timeout: <%= ENV['STATEMENT_TIMEOUT'] || 2500 %>
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
url: <%= ENV.fetch('DATABASE_URL', '') %>
|
||||
database: PracticalDeveloper_development
|
||||
|
||||
# The specified database role being used to connect to postgres.
|
||||
|
|
@ -62,6 +62,7 @@ development:
|
|||
test:
|
||||
<<: *default
|
||||
host: localhost
|
||||
url: <%= ENV.fetch('DATABASE_URL', '') %>
|
||||
database: PracticalDeveloper_test<%= ENV['TEST_ENV_NUMBER'] %>
|
||||
|
||||
# As with config/secrets.yml, you never want to store sensitive information,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
# rubocop:disable Metrics/BlockLength
|
||||
#
|
||||
def yarn_integrity_enabled?
|
||||
ENV.fetch("YARN_INTEGRITY_ENABLED", "true") == "true"
|
||||
end
|
||||
|
||||
Rails.application.configure do
|
||||
# Verifies that versions and hashed value of the package contents in the project's package.json
|
||||
config.webpacker.check_yarn_integrity = true
|
||||
config.webpacker.check_yarn_integrity = yarn_integrity_enabled?
|
||||
|
||||
# Replace with a lambda or method name defined in ApplicationController
|
||||
# to implement access control for the Flipflop dashboard.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
if Rails.env.development? && ENV["RACK_TIMEOUT_WAIT_TIMEOUT"].nil?
|
||||
ENV["RACK_TIMEOUT_WAIT_TIMEOUT"] = "100"
|
||||
ENV["RACK_TIMEOUT_SERVICE_TIMEOUT"] = "100"
|
||||
ENV["RACK_TIMEOUT_WAIT_TIMEOUT"] = "100000"
|
||||
ENV["RACK_TIMEOUT_SERVICE_TIMEOUT"] = "100000"
|
||||
end
|
||||
|
||||
Rack::Timeout.unregister_state_change_observer(:logger) if Rails.env.development?
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ User.clear_index!
|
|||
user = User.create!(
|
||||
name: name = Faker::Name.unique.name,
|
||||
summary: Faker::Lorem.paragraph_by_chars(199, false),
|
||||
remote_profile_image_url: Faker::Avatar.image(nil, "300x300", "png", "set2", "bg2"),
|
||||
profile_image: File.open("#{Rails.root}/app/assets/images/#{rand(1..40)}.png"),
|
||||
website_url: Faker::Internet.url,
|
||||
twitter_username: Faker::Internet.username(name),
|
||||
email_comment_notifications: false,
|
||||
|
|
|
|||
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
version: "3"
|
||||
services:
|
||||
web: &rails_base
|
||||
build:
|
||||
dockerfile: Dockerfile
|
||||
context: .
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
RAILS_ENV: development
|
||||
DATABASE_URL: postgres://postgres:mysecretpassword@db:5432/postgres
|
||||
YARN_INTEGRITY_ENABLED: "false"
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
command: bundle exec rails server -b 0.0.0.0 -p 3000
|
||||
jobs:
|
||||
ports: []
|
||||
<<: *rails_base
|
||||
command: rails jobs:work
|
||||
webpacker:
|
||||
ports: []
|
||||
<<: *rails_base
|
||||
command: ./bin/webpack-dev-server
|
||||
db:
|
||||
image: postgres
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
|
@ -91,5 +91,10 @@
|
|||
"prop-types": "^15.6.2",
|
||||
"pusher-js": "^4.3.1",
|
||||
"twilio-video": "^1.14.0"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue