From 69cc727c10f3741c58f7ebbd403032fc7b7b5eae Mon Sep 17 00:00:00 2001 From: yonehara Date: Sat, 25 Nov 2023 13:52:01 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E7=95=AA=E7=92=B0=E5=A2=83=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 2 -- Dockerfile | 3 --- app/controllers/health_checks_controller.rb | 2 +- config/database.yml | 1 + config/environments/production.rb | 2 +- config/initializers/cors.rb | 2 +- docker-compose.dev.yml => docker-compose.yml | 10 +++++++++- entrypoint.sh | 8 +------- public/404.html | 13 +++++++++++++ storage/development.sqlite3 | Bin 20480 -> 20480 bytes 10 files changed, 27 insertions(+), 16 deletions(-) rename docker-compose.dev.yml => docker-compose.yml (74%) create mode 100644 public/404.html diff --git a/.dockerignore b/.dockerignore index bb56daf..52f3381 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,8 +11,6 @@ !/.env*.erb # Ignore all default key files. -/config/master.key -/config/credentials/*.key # Ignore all logfiles and tempfiles. /log/* diff --git a/Dockerfile b/Dockerfile index 00d9a8a..083419f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/app/controllers/health_checks_controller.rb b/app/controllers/health_checks_controller.rb index f38a8a1..fc40d44 100644 --- a/app/controllers/health_checks_controller.rb +++ b/app/controllers/health_checks_controller.rb @@ -1,5 +1,5 @@ class HealthChecksController < ApplicationController def index - head :ok + render json: { message: '成功' }, status: :ok end end diff --git a/config/database.yml b/config/database.yml index b405fa4..ddda5ae 100644 --- a/config/database.yml +++ b/config/database.yml @@ -22,6 +22,7 @@ test: production: <<: *default + adapter: mysql2 database: <%= ENV["DB_DATABASE"] %> username: <%= ENV["DB_USERNAME"] %> password: <%= ENV["DB_PASSWORD"] %> diff --git a/config/environments/production.rb b/config/environments/production.rb index 8233de8..5f7d11b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -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) diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 588af99..17ad9cb 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -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, diff --git a/docker-compose.dev.yml b/docker-compose.yml similarity index 74% rename from docker-compose.dev.yml rename to docker-compose.yml index f8d2c3b..a4b9bdf 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.yml @@ -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 @@ -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: diff --git a/entrypoint.sh b/entrypoint.sh index 76af5ba..e2b6a65 100755 --- a/entrypoint.sh +++ b/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 diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000..c24200b --- /dev/null +++ b/public/404.html @@ -0,0 +1,13 @@ + + + + + + Document + + +

+ 404 +

+ + diff --git a/storage/development.sqlite3 b/storage/development.sqlite3 index a99a162dfcf969db3f6ce82fd81201de5ab58871..81afc8c91c460d2fd43c812bd50c3662c6678be4 100644 GIT binary patch delta 75 zcmZozz}T>WaRZwH%LWGi4Vwi8mh#K``!TXAD>^!+=9Og@<>%$5=9Lr_<)@S;mt^MW fO+I6WaRZwH%X$X>^_v9+mh#K`GqNfxJ36N3m1P#?=jEp6m87JWrRL-pfS8ld Q*egxGVlT*OzQ{oU0ECehRR910