-
Notifications
You must be signed in to change notification settings - Fork 25
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
Dockerize application #15
Open
gruz0
wants to merge
9
commits into
davydovanton:master
Choose a base branch
from
gruz0:feature/dockerize-app
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
08b27df
Dockerize application
gruz0 52b9783
Minimize Docker image size
gruz0 ee68610
Ignore .env.test
gruz0 b27f9ab
Add postgresql-client to run tests inside Docker
gruz0 97dea3a
Update env files
gruz0 1841326
Move documentation from README.md to CONTRIBUTING.md
gruz0 c8c7910
Increase Redis ConnectionPool size to 12 because of Sidekiq
gruz0 46067d6
Add Sidekiq to dockerized app
gruz0 4967999
Revert Redis ConnectionPool size to 10
gruz0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# Define ENV variables for development environment | ||
DATABASE_URL="postgresql://localhost/ruby_jobs_development" | ||
SERVE_STATIC_ASSETS="true" | ||
WEB_SESSIONS_SECRET="238d8ece1579f59647fe3d7c5ca2c78f02142a6392506a929d14c46424e52543" | ||
MODERATION_SESSIONS_SECRET="f62e64af694897dd5a3b949891f2715ada568401017905098809aa80e8943dd0" | ||
REDISTOGO_URL="redis://localhost:6379" | ||
HANAMI_ENV=development | ||
|
||
MODERATION_LOGIN="login" | ||
MODERATION_PASSWORD="password" | ||
# For local development: | ||
DATABASE_URL=postgresql://localhost/rubyjobs_development | ||
REDISTOGO_URL=redis://localhost:6379 | ||
|
||
ROLLBAR_KEY = 'test' | ||
# For Docker development uncomment these lines (and comment similar lines above): | ||
# DATABASE_URL=postgres://rubyjobs@postgres/rubyjobs_development | ||
# REDISTOGO_URL=redis://redis:6379 | ||
|
||
SERVE_STATIC_ASSETS=true | ||
WEB_SESSIONS_SECRET=238d8ece1579f59647fe3d7c5ca2c78f02142a6392506a929d14c46424e52543 | ||
MODERATION_SESSIONS_SECRET=f62e64af694897dd5a3b949891f2715ada568401017905098809aa80e8943dd0 | ||
|
||
MODERATION_LOGIN=login | ||
MODERATION_PASSWORD=password | ||
|
||
ROLLBAR_KEY=test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Define ENV variables for test environment | ||
|
||
# For local development: | ||
DATABASE_URL=postgresql://localhost/rubyjobs_test | ||
REDISTOGO_URL=redis://localhost:6379 | ||
|
||
# For Docker development uncomment these lines (and comment similar lines above): | ||
# DATABASE_URL=postgres://rubyjobs@postgres/rubyjobs_test | ||
# REDISTOGO_URL=redis://redis:6379 | ||
# DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true | ||
|
||
SERVE_STATIC_ASSETS=true | ||
WEB_SESSIONS_SECRET=ef09acb9b6d59ea2c7565bfbeb0fce5253445d6a8c784339d5cea71305ed8b85 | ||
MODERATION_SESSIONS_SECRET=d0111ed3e5f320d69e38f88fc351197cb56e2d67bf4ba61c2f0a294fb3bfc534 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/public/assets* | ||
/tmp | ||
/coverage | ||
|
||
.env.development | ||
.env.test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
RubyJobs.dev is an open source project and we would love you to help us make it better. | ||
|
||
## Reporting Issues | ||
|
||
A well formatted issue is appreciated, and goes a long way in helping us help you. | ||
|
||
* Make sure you have a [GitHub account](https://github.com/signup/free) | ||
* Submit a [Github issue](https://github.com/davydovanton/rubyjobs.dev/issues/new) by: | ||
* Clearly describing the issue | ||
* Provide a descriptive summary | ||
* Explain the expected behavior | ||
* Explain the actual behavior | ||
* Provide steps to reproduce the actual behavior | ||
* Put application stacktrace as text (in a [Gist](https://gist.github.com) for bonus points) | ||
* Any relevant stack traces | ||
|
||
If you provide code, make sure it is formatted with the triple backticks (\`). | ||
|
||
At this point, we'd love to tell you how long it will take for us to respond, | ||
but we just don't know. | ||
|
||
## Pull requests | ||
|
||
We accept pull requests to RubyJobs.dev for: | ||
|
||
* Fixing bugs | ||
* Adding new features | ||
|
||
Not all features proposed will be added but we are open to having a conversation | ||
about a feature you are championing. | ||
|
||
Here's a quick guide: | ||
|
||
1. Fork the repo. | ||
|
||
2. Run the tests. | ||
|
||
3. Create a new branch and make your changes. This includes tests for features! | ||
|
||
4. Push to your fork and submit a pull request. For more information, see | ||
[Github's pull request help section](https://help.github.com/articles/using-pull-requests/). | ||
|
||
At this point you're waiting on us. Expect a conversation regarding your pull | ||
request, questions, clarifications, and so on. | ||
|
||
## How to install project | ||
|
||
The first thing what you need to start project is copying sample configs: | ||
|
||
```bash | ||
$ cp .env.development.sample .env.development | ||
$ cp .env.test.sample .env.test | ||
``` | ||
|
||
If you want to contribute inside Docker instead of local development, | ||
then you need to uncomment `DATABASE_URL`, `REDISTOGO_URL` and other variables | ||
in Docker section in these configs. | ||
|
||
Project will be available on [http://localhost:2300](http://localhost:2300). | ||
|
||
### Local development | ||
|
||
```bash | ||
$ bundle install | ||
$ bundle exec hanami db prepare | ||
$ bundle exec hanami s | ||
``` | ||
|
||
### Docker development | ||
|
||
```bash | ||
$ make dockerize | ||
``` | ||
|
||
## How to run tests | ||
|
||
### Local development | ||
|
||
```bash | ||
$ HANAMI_ENV=test bundle exec hanami db prepare | ||
$ bundle exec rspec | ||
``` | ||
|
||
### Docker development | ||
|
||
```bash | ||
$ make shell | ||
$ HANAMI_ENV=test bundle exec hanami db prepare | ||
$ bundle exec rspec | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM ruby:2.5.0-alpine | ||
|
||
# NOTE: postgresql-client required by `hanami db prepare` to create test database | ||
RUN apk add --update --no-cache build-base postgresql-dev postgresql-client tzdata git \ | ||
&& gem install -N bundler \ | ||
&& bundle config --global silence_root_warning 1 \ | ||
&& echo -e 'gem: --no-document' >> /etc/gemrc \ | ||
&& rm -rf /var/cache/apk/* \ | ||
&& rm -rf /usr/local/bundle/cache/*.gem \ | ||
&& find /usr/local/bundle/gems/ -name "*.c" -delete \ | ||
&& find /usr/local/bundle/gems/ -name "*.o" -delete | ||
|
||
WORKDIR /app | ||
|
||
COPY Gemfile Gemfile.lock ./ | ||
RUN bundle install -j $(nproc) --quiet | ||
|
||
COPY . ./ | ||
|
||
ENTRYPOINT ["bundle", "exec"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.PHONY: help dockerize shell | ||
|
||
help: | ||
@echo 'Available targets:' | ||
@echo ' make dockerize' | ||
@echo ' make shell' | ||
|
||
dockerize: | ||
docker-compose -f docker-compose.development.yml up --build | ||
|
||
shell: | ||
docker-compose -f docker-compose.development.yml exec web sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
version: '3' | ||
|
||
services: | ||
redis: | ||
image: redis:latest | ||
|
||
postgres: | ||
image: postgres:9.6.2-alpine | ||
environment: | ||
POSTGRES_USER: safelylaunch | ||
POSTGRES_DB: core | ||
POSTGRES_USER: rubyjobs | ||
POSTGRES_DB: rubyjobs_development | ||
ports: | ||
- 5432:5432 | ||
|
||
web: | ||
build: . | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.development | ||
command: sh -c "hanami db migrate && hanami server --host=0.0.0.0" | ||
volumes: | ||
- .:/app | ||
ports: | ||
- "2300:2300" | ||
- 2300:2300 | ||
depends_on: | ||
- postgres | ||
environment: | ||
DATABASE_URL: postgres://safelylaunch@postgres/core | ||
HANAMI_ENV: development | ||
- redis | ||
|
||
sidekiq: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.development | ||
command: bundle exec sidekiq -r ./config/boot.rb -c 7 | ||
volumes: | ||
- .:/app | ||
depends_on: | ||
- postgres | ||
- redis |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we need to add
sidekiq
tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done