Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

refactor: 💡 Cloud Run 正常デプロイに際していじくった値をリファクタした #160

Merged
merged 1 commit into from
Nov 19, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ env:
# TODO: Git のタグを取得して、イメージのタグにする
DOCKER_IMAGE: asia-northeast1-docker.pkg.dev/${{ secrets.CLOUD_RUN_PROJECT }}/cloud-run-source-deploy/gensosenkyo-2017
GCP_REGION: ${{ secrets.CLOUD_RUN_REGION }}
GCP_AUTH_HOST: asia-northeast1-docker.pkg.dev
CLOUD_RUN_SERVICE_NAME: gensosenkyo-2017
RAILS_ENV: test
PG_HOST_TEST: localhost
PG_PORT_TEST: 5432
Expand Down Expand Up @@ -57,8 +59,6 @@ jobs:
if: ${{ github.ref_name == 'main' }}
name: Cloud Run に production デプロイする
runs-on: ubuntu-latest
env:
RAILS_ENV: production
steps:
- name: ソースコードをチェックアウトする
uses: actions/checkout@v3
Expand All @@ -68,7 +68,7 @@ jobs:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }}
- name: GCP の CLI の認証を行う
run: |
gcloud auth configure-docker asia-northeast1-docker.pkg.dev
gcloud auth configure-docker ${{ env.GCP_AUTH_HOST }}
- name: Docker イメージ をビルドする
run: |
docker build -t ${{ env.DOCKER_IMAGE }} .
Expand All @@ -78,6 +78,6 @@ jobs:
- name: Deploy to Cloud Run
uses: google-github-actions/deploy-cloudrun@v0
with:
service: gensosenkyo-2017
service: ${{ env.CLOUD_RUN_SERVICE_NAME }}
image: ${{ env.DOCKER_IMAGE }}
region: ${{ env.GCP_REGION }}
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
FROM ruby:3.1.2
ENV LANG C.UTF-8

# TODO: development のときはどうするか
ENV RAILS_ENV production

RUN apt update -qq && apt install -y build-essential libpq-dev nodejs
RUN gem install bundler
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
Expand All @@ -19,7 +16,7 @@ COPY Gemfile.lock /myapp/Gemfile.lock

RUN gem install bundler

# TODO: 開発環境として Docker を利用する場合はどうするか
# TODO: production ビルド前提なので、開発環境として Docker を利用する場合は Dockerfile を分ける
RUN bundle config set --local without 'test development'
RUN bundle install

Expand Down
8 changes: 3 additions & 5 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
# timeout: 5000
# strict: false

development:
<<: *default
host: <%= ENV['PG_HOST_DEVELOPMENT'] || 'localhost' %>
port: <%= ENV['PG_PORT_DEVELOPMENT'] || 5432 %>
username: <%= ENV['PG_USERNAME_DEVELOPMENT'] || 'root' %>
password: <%= ENV['PG_PASSWORD_DEVELOPMENT'] || 'password' %>
database: <%= ENV['PG_DATABASE_DEVELOPMENT'] || 'gss2017_development' %>
database: gss2017_development
template: template0
collation: ja_JP.UTF-8
ctype: ja_JP.UTF-8
Expand All @@ -22,7 +20,7 @@ production:
port: <%= ENV['PG_PORT_PRODUCTION'] || 5432 %>
username: <%= ENV['PG_USERNAME_PRODUCTION'] || 'root' %>
password: <%= ENV['PG_PASSWORD_PRODUCTION'] || 'password' %>
database: 'gss2017_production'
database: gss2017_production
template: template0
collation: ja_JP.UTF-8
ctype: ja_JP.UTF-8
Expand All @@ -33,4 +31,4 @@ test:
port: <%= ENV['PG_PORT_TEST'] || 5432 %>
username: <%= ENV['PG_USERNAME_TEST'] || 'gss2017' %>
password: <%= ENV['PG_PASSWORD_TEST'] || 'gss2017_password' %>
database: <%= ENV['PG_DATABASE_TEST'] || 'gss2017_test' %>
database: gss2017_test
3 changes: 0 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ if [ -n "$PORT" ]; then
RAILS_PORT=$PORT
fi

# TODO: development のときはどうするか
RAILS_ENV=production

bin/rails assets:precompile
bin/rails db:create
bin/rails db:migrate
Expand Down