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

Commit 01afcd3

Browse files
authored
refactor: 💡 Cloud Run 正常デプロイに際していじくった値をリファクタした (#160)
1 parent 6300f13 commit 01afcd3

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

.github/workflows/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
# TODO: Git のタグを取得して、イメージのタグにする
1313
DOCKER_IMAGE: asia-northeast1-docker.pkg.dev/${{ secrets.CLOUD_RUN_PROJECT }}/cloud-run-source-deploy/gensosenkyo-2017
1414
GCP_REGION: ${{ secrets.CLOUD_RUN_REGION }}
15+
GCP_AUTH_HOST: asia-northeast1-docker.pkg.dev
16+
CLOUD_RUN_SERVICE_NAME: gensosenkyo-2017
1517
RAILS_ENV: test
1618
PG_HOST_TEST: localhost
1719
PG_PORT_TEST: 5432
@@ -57,8 +59,6 @@ jobs:
5759
if: ${{ github.ref_name == 'main' }}
5860
name: Cloud Run に production デプロイする
5961
runs-on: ubuntu-latest
60-
env:
61-
RAILS_ENV: production
6262
steps:
6363
- name: ソースコードをチェックアウトする
6464
uses: actions/checkout@v3
@@ -68,7 +68,7 @@ jobs:
6868
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }}
6969
- name: GCP の CLI の認証を行う
7070
run: |
71-
gcloud auth configure-docker asia-northeast1-docker.pkg.dev
71+
gcloud auth configure-docker ${{ env.GCP_AUTH_HOST }}
7272
- name: Docker イメージ をビルドする
7373
run: |
7474
docker build -t ${{ env.DOCKER_IMAGE }} .
@@ -78,6 +78,6 @@ jobs:
7878
- name: Deploy to Cloud Run
7979
uses: google-github-actions/deploy-cloudrun@v0
8080
with:
81-
service: gensosenkyo-2017
81+
service: ${{ env.CLOUD_RUN_SERVICE_NAME }}
8282
image: ${{ env.DOCKER_IMAGE }}
8383
region: ${{ env.GCP_REGION }}

Dockerfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
FROM ruby:3.1.2
22
ENV LANG C.UTF-8
33

4-
# TODO: development のときはどうするか
5-
ENV RAILS_ENV production
6-
74
RUN apt update -qq && apt install -y build-essential libpq-dev nodejs
85
RUN gem install bundler
96
RUN apt-get update && apt-get install -y curl apt-transport-https wget && \
@@ -19,7 +16,7 @@ COPY Gemfile.lock /myapp/Gemfile.lock
1916

2017
RUN gem install bundler
2118

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

config/database.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ default: &default
22
adapter: postgresql
33
encoding: unicode
44
pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %>
5-
# timeout: 5000
6-
# strict: false
75

86
development:
97
<<: *default
108
host: <%= ENV['PG_HOST_DEVELOPMENT'] || 'localhost' %>
119
port: <%= ENV['PG_PORT_DEVELOPMENT'] || 5432 %>
1210
username: <%= ENV['PG_USERNAME_DEVELOPMENT'] || 'root' %>
1311
password: <%= ENV['PG_PASSWORD_DEVELOPMENT'] || 'password' %>
14-
database: <%= ENV['PG_DATABASE_DEVELOPMENT'] || 'gss2017_development' %>
12+
database: gss2017_development
1513
template: template0
1614
collation: ja_JP.UTF-8
1715
ctype: ja_JP.UTF-8
@@ -22,7 +20,7 @@ production:
2220
port: <%= ENV['PG_PORT_PRODUCTION'] || 5432 %>
2321
username: <%= ENV['PG_USERNAME_PRODUCTION'] || 'root' %>
2422
password: <%= ENV['PG_PASSWORD_PRODUCTION'] || 'password' %>
25-
database: 'gss2017_production'
23+
database: gss2017_production
2624
template: template0
2725
collation: ja_JP.UTF-8
2826
ctype: ja_JP.UTF-8
@@ -33,4 +31,4 @@ test:
3331
port: <%= ENV['PG_PORT_TEST'] || 5432 %>
3432
username: <%= ENV['PG_USERNAME_TEST'] || 'gss2017' %>
3533
password: <%= ENV['PG_PASSWORD_TEST'] || 'gss2017_password' %>
36-
database: <%= ENV['PG_DATABASE_TEST'] || 'gss2017_test' %>
34+
database: gss2017_test

entrypoint.sh

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ if [ -n "$PORT" ]; then
66
RAILS_PORT=$PORT
77
fi
88

9-
# TODO: development のときはどうするか
10-
RAILS_ENV=production
11-
129
bin/rails assets:precompile
1310
bin/rails db:create
1411
bin/rails db:migrate

0 commit comments

Comments
 (0)