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

本番環境用の設定ファイル修正 #10

Merged
merged 1 commit into from Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .dockerignore
Expand Up @@ -11,8 +11,6 @@
!/.env*.erb

# Ignore all default key files.
/config/master.key
/config/credentials/*.key

# Ignore all logfiles and tempfiles.
/log/*
Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Expand Up @@ -21,8 +21,5 @@ COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]

VOLUME ["/cat-img-api/public"]
VOLUME ["/cat-img-api/tmp"]


CMD ["unicorn", "-p", "3000", "-c", "/cat-img-api/config/unicorn.rb", "-E", "$RAILS_ENV"]
2 changes: 1 addition & 1 deletion app/controllers/health_checks_controller.rb
@@ -1,5 +1,5 @@
class HealthChecksController < ApplicationController
def index
head :ok
render json: { message: '成功' }, status: :ok
end
end
1 change: 1 addition & 0 deletions config/database.yml
Expand Up @@ -22,6 +22,7 @@ test:

production:
<<: *default
adapter: mysql2
database: <%= ENV["DB_DATABASE"] %>
username: <%= ENV["DB_USERNAME"] %>
password: <%= ENV["DB_PASSWORD"] %>
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Expand Up @@ -42,7 +42,7 @@
# config.assume_ssl = true

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
config.force_ssl = false

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/cors.rb
Expand Up @@ -7,7 +7,7 @@

Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "http://localhost:3001"
origins "web.judging-cats.com","api.judging-cats.com"

resource "*",
headers: :any,
Expand Down
10 changes: 9 additions & 1 deletion docker-compose.dev.yml → docker-compose.yml
Expand Up @@ -10,12 +10,15 @@ services:
- '3000:3000'
volumes:
- .:/cat-img-api
- public-data:/cat-img-api/public
- tmp-data:/cat-img-api/tmp
depends_on:
- db
links:
- db
environment:
RAILS_ENV: development
RAILS_ENV: production
DB_DATABASE: cat-img-mysql
DB_USER: root
DB_PASSWORD: root
DB_HOST: db
Expand All @@ -40,6 +43,11 @@ services:
restart: always #明示的にstopさせるまでリスタートする。(失敗するたび遅延あり)
depends_on:
- web
volumes:
- public-data:/cat-img-api/public
- tmp-data:/cat-img-api/tmp

volumes:
public-data:
mysql-data:
tmp-data:
8 changes: 1 addition & 7 deletions entrypoint.sh
@@ -1,16 +1,10 @@
#!/bin/sh
set -e

rm -f tmp/pids/server.pid
rm -f tmp/pids/unicorn.pid
mkdir -p tmp/sockets
mkdir -p tmp/pids

until mysqladmin ping -h $DB_HOST -P 3306 -u root --silent; do
echo "waiting for mysql..."
sleep 3s
done
echo "success to connect mysql"

bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:migrate:status
Expand Down
13 changes: 13 additions & 0 deletions public/404.html
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>
404
</p>
</body>
</html>
Binary file modified storage/development.sqlite3
Binary file not shown.