-
Notifications
You must be signed in to change notification settings - Fork 0
Fix Docker setup #98
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
Open
mateusdeap
wants to merge
18
commits into
main
Choose a base branch
from
fix-docker-setup
base: main
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
Fix Docker setup #98
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
db8adcb
Update ignored files by docker
mateusdeap d38d970
Set docker syntax directive
mateusdeap e2c8f6e
Configure bundler settings in the environment
mateusdeap c55ab04
Copy entrypoint before app files
mateusdeap 79f1da9
Tie web_next dependency on service_healthy
mateusdeap 1097944
Use absolute path for BUNDLE_GEMFILE in web_next
mateusdeap 70c923a
Build web_next image
mateusdeap 6e145c6
Setup BUNDLE_GEMFILE as a build argument and environment variable
mateusdeap 7a67b8b
Only copy the needed files for setup in the image
mateusdeap 6bcdd10
Modify web_next
mateusdeap 0fd5f61
Remove dependency on web from web_next
mateusdeap f4961b0
Add docker scripts
mateusdeap 534b075
Update README instructions
mateusdeap d11af94
Update execution permissions on bin/docker/run
mateusdeap 6683060
Remove CI execution paths
mateusdeap 3450aca
Readd build-essential and nodejs
mateusdeap 18dc8b3
Set DOCKER_PREFIX in all cases
mateusdeap 1d1cebc
Add .env.local and .env.test to gitignore
mateusdeap 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 hidden or 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,5 +1,7 @@ | ||
| .git | ||
| .circleci | ||
| .github | ||
| .DS_Store | ||
| coverage | ||
| log/* | ||
| tmp/* | ||
| !log/.keep | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,10 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
| cd "$(dirname "$0")/../.." | ||
| if [ "$(basename "$BUNDLE_GEMFILE")" = "Gemfile.next" ]; then | ||
| CONTAINER=web_next | ||
| else | ||
| CONTAINER=web | ||
| fi | ||
| exec docker compose run --rm "$CONTAINER" "$@" | ||
|
|
This file contains hidden or 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,39 @@ | ||
| #!/usr/bin/env ruby | ||
| require "pathname" | ||
| require "fileutils" | ||
| include FileUtils | ||
|
|
||
| # path to your application root. | ||
| APP_ROOT = Pathname.new File.expand_path("../..", __dir__) | ||
|
|
||
| def system!(*args) | ||
| system(*args) || abort("\n== Command #{args} failed ==") | ||
| end | ||
|
|
||
| CONTAINER = ENV["BUNDLE_GEMFILE"] == "Gemfile.next" ? "web_next" : "web" | ||
| DOCKER_PREFIX = "docker compose run --rm #{CONTAINER}" | ||
|
|
||
| chdir APP_ROOT do | ||
| # This script is a starting point to setup your application. | ||
| # Add necessary setup steps to this file. | ||
|
|
||
| puts "== Copy .env ==" | ||
| # We use .env.local because we are using DotenvValidator and there's a known issue with docker-compose: [link](https://github.com/fastruby/dotenv_validator#if-you-use-docker-compose-read-this) | ||
| # The symlink is created because `.env.local` is not visible in testing environments but | ||
| # we don't want to maintain 2 separate files. This follows [this table](https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use) | ||
| unless File.exist?(".env.local") | ||
| cp ".env.sample", ".env.local" | ||
| system! "ln -s .env.local .env.test" | ||
|
Comment on lines
+25
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should add these files to the .gitignore file |
||
| end | ||
|
|
||
| puts "== Setup Database ==" | ||
| puts "\n== Copying sample files ==" | ||
| unless File.exist?("config/database.yml") | ||
| cp "config/database.yml.sample", "config/database.yml" | ||
| end | ||
|
|
||
| puts "== Build images ==" | ||
| system! "docker compose build #{CONTAINER}" | ||
|
|
||
| system! "#{DOCKER_PREFIX} rails db:create db:migrate" | ||
| end | ||
This file contains hidden or 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,9 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
| cd "$(dirname "$0")/../.." | ||
| if [ "$(basename "$BUNDLE_GEMFILE")" = "Gemfile.next" ]; then | ||
| CONTAINER=web_next | ||
| else | ||
| CONTAINER=web | ||
| fi | ||
| exec docker compose up "$CONTAINER" "$@" |
This file contains hidden or 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
Oops, something went wrong.
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.
this line is being removed but it's the only line that mentions that the "next" server runs in port 3001
when you run the "next" app, the log shows port 3000 (which is the one inside the container)
but if you click that link, it fails, because docker is exposing it as 3001 instead
I think we should change the
commandof the web-next service to include "-p 3001" and theportto be "3001:3001", so then the logs showsListening on http://0.0.0.0:3001with the correct port and clicking it opens the browser in the correct url