-
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.
Merge pull request #160 from splaplapla/cloudrun
cloudrunへデプロイする
- Loading branch information
Showing
10 changed files
with
105 additions
and
31 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
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,64 @@ | ||
name: Review App | ||
|
||
on: pull_request | ||
|
||
env: | ||
PROJECT_ID: jiikko | ||
REGISTRY_HOST: asia-northeast1-docker.pkg.dev | ||
SERVICE_NAME: pbm-cloud | ||
REPOSITORY_NAME: pbm-cloud | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: "auth" | ||
uses: "google-github-actions/auth@v0" | ||
with: | ||
credentials_json: "${{ secrets.GCP_CREDENTIALS }}" | ||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v0" | ||
- name: "Use gcloud CLI" | ||
run: | | ||
gcloud auth list | ||
gcloud info | ||
- name: Authorize Docker push | ||
run: gcloud auth configure-docker "${REGISTRY_HOST}" | ||
- name: Build Docker image | ||
run: | | ||
echo "${REGISTRY_HOST}/$PROJECT_ID/$REPOSITORY_NAME/web:pr-${{ github.event.number }}" | ||
docker build --target production -t "${REGISTRY_HOST}/$PROJECT_ID/$REPOSITORY_NAME/web:pr-${{ github.event.number }}" . | ||
docker push "${REGISTRY_HOST}/$PROJECT_ID/$REPOSITORY_NAME/web:pr-${{ github.event.number }}" | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: "auth" | ||
uses: "google-github-actions/auth@v0" | ||
with: | ||
credentials_json: "${{ secrets.GCP_CREDENTIALS }}" | ||
- name: Deploy to Cloud Run | ||
env: | ||
DATABASE_URL: ${{ secrets.DATABASE_URL }} | ||
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }} | ||
run: |- | ||
gcloud run deploy "$SERVICE_NAME" \ | ||
--project="$PROJECT_ID" \ | ||
--platform=managed \ | ||
--image="${REGISTRY_HOST}/$PROJECT_ID/$REPOSITORY_NAME/web:pr-${{ github.event.number }}" \ | ||
--region="asia-northeast1" \ | ||
--tag=pr-${{ github.event.number }} \ | ||
--set-env-vars="DATABASE_URL=${DATABASE_URL},SECRET_KEY_BASE=${SECRET_KEY_BASE}" \ | ||
--no-traffic \ | ||
--allow-unauthenticated | ||
- name: Notify the review app url | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
URL: ${{ github.event.pull_request.html_url }} | ||
run: |- | ||
cat << EOF > comments | ||
https://pr-${{ github.event.number }}---pbm-cloud-7hrjn5ej3q-an.a.run.app/ がデプロイされました | ||
EOF | ||
gh pr comment -F ./comments "${URL}" |
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 |
---|---|---|
@@ -1,17 +1,29 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM jiikkko/procon_bypass_man_cloud-base:latest | ||
|
||
ARG RAILS_ENV=production | ||
FROM jiikkko/procon_bypass_man_cloud-base:latest as base | ||
|
||
WORKDIR /app | ||
COPY . . | ||
|
||
COPY Gemfile /app/Gemfile | ||
COPY Gemfile.lock /app/Gemfile.lock | ||
|
||
RUN yarn | ||
|
||
RUN bundle config set --local path '/vendor/bundle' | ||
RUN bundle check || bundle install --jobs 100 | ||
|
||
# Configure the main process to run when running the image | ||
CMD ["bin/start_server"] | ||
|
||
# target dev | ||
FROM base as dev | ||
LABEL image.type=dev | ||
RUN bundle install --jobs 100 | ||
|
||
|
||
# target production | ||
FROM base as production | ||
LABEL image.type=production | ||
ENV RAILS_ENV production | ||
|
||
COPY . . | ||
RUN bundle install --jobs 100 --without development,test | ||
RUN yarn | ||
COPY . /app | ||
RUN SECRET_KEY_BASE=dummy SKIP_TO_LOAD_CREDENTIALS=1 bundle exec rails assets:precompile | ||
|
||
CMD ["bin/start.sh"] |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
web: bin/start_server -p 5000 -b 0.0.0.0 | ||
web: bin/rails server -p 5000 -b 0.0.0.0 | ||
css: yarn build:css --watch |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/bash | ||
|
||
bundle exec rails assets:precompile | ||
bundle exec rails s -p ${PORT:-3000} -e production | ||
bundle exec rails s -p ${PORT:-3000} |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
build: | ||
docker: | ||
web: Dockerfile | ||
args: | ||
- --target=production | ||
config: | ||
RAILS_ENV: production | ||
run: | ||
|