-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base Dockerfile, entrypoint.sh, and docker-compose.yml on https://docs.docker.com/samples/rails/ Ignore all temporary folders, .git, and non-necessary files on .dockerignore based on https://codefresh.io/docker-tutorial/not-ignore-dockerignore-2/ Create .env file with POSTGRES_USER and POSTGRES_PASSWORD used for postgres on docker-compose.yml I need to spend some time seeing what solution I can use for environment variables in docker locally and production Since at the moment I have both .env and environment_variables.rb Add host:db to database.yml in order for the postgres port to be available on docker
- Loading branch information
Showing
7 changed files
with
71 additions
and
5 deletions.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.git | ||
/tmp | ||
/log | ||
|
||
.byebug_history | ||
.gitignore | ||
.dockerignore | ||
.rubocop.yml | ||
.ruby-version | ||
README.rdoc | ||
|
||
/config/secrets.yml | ||
/config/environment_variables.rb | ||
.env |
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,5 @@ | ||
# Used for docker-compose.yml. | ||
# POSTGRES_USER and POSTGRES_PASSWORD need to match ones in database.yml | ||
|
||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= |
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 |
---|---|---|
|
@@ -25,3 +25,4 @@ | |
#ignore config secrets and environment variables | ||
/config/secrets.yml | ||
/config/environment_variables.rb | ||
.env |
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,18 @@ | ||
# Based on https://docs.docker.com/samples/rails/ | ||
|
||
# syntax=docker/dockerfile:1 | ||
FROM ruby:3.0.1 | ||
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client | ||
WORKDIR /myapp | ||
COPY Gemfile /myapp/Gemfile | ||
COPY Gemfile.lock /myapp/Gemfile.lock | ||
RUN bundle install | ||
|
||
# Add a script to be executed every time the container starts. | ||
COPY entrypoint.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/entrypoint.sh | ||
ENTRYPOINT ["entrypoint.sh"] | ||
EXPOSE 3000 | ||
|
||
# Configure the main process to run when running the image | ||
CMD ["rails", "server", "-b", "0.0.0.0"] |
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
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,19 @@ | ||
# Based on https://docs.docker.com/samples/rails/ | ||
|
||
version: "3.9" | ||
services: | ||
db: | ||
image: postgres | ||
volumes: | ||
- ./tmp/db:/var/lib/postgresql/data | ||
env_file: | ||
- .env | ||
web: | ||
build: . | ||
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" | ||
volumes: | ||
- .:/myapp | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- db |
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,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Remove a potentially pre-existing server.pid for Rails. | ||
rm -f /myapp/tmp/pids/server.pid | ||
|
||
# Then exec the container's main process (what's set as CMD in the Dockerfile). | ||
exec "$@" | ||
|
||
# Based on https://docs.docker.com/samples/rails/ |