-
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.
feat: 🎸 Docker を導入した (for production) (#539)
- Loading branch information
1 parent
0d3e7d6
commit 88d0405
Showing
4 changed files
with
119 additions
and
35 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,27 @@ | ||
FROM ruby:3.1.3 | ||
ENV LANG C.UTF-8 | ||
|
||
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 && \ | ||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ | ||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ | ||
apt-get update && apt-get install -y yarn | ||
|
||
RUN mkdir /myapp | ||
WORKDIR /myapp | ||
|
||
COPY Gemfile /myapp/Gemfile | ||
COPY Gemfile.lock /myapp/Gemfile.lock | ||
|
||
RUN gem install bundler | ||
|
||
# TODO: production ビルド前提なので、開発環境として Docker を利用する場合は Dockerfile を分ける | ||
RUN bundle config set --local without 'test development' | ||
RUN bundle install | ||
|
||
COPY . /myapp | ||
|
||
# Add a script to be executed every time the container starts. | ||
COPY entrypoint.sh /usr/bin/ | ||
ENTRYPOINT ["entrypoint.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
RAILS_PORT=3000 | ||
if [ -n "$PORT" ]; then | ||
RAILS_PORT=$PORT | ||
fi | ||
|
||
bin/rails assets:precompile | ||
bin/rails db:create | ||
bin/rails db:migrate | ||
bin/rails db:seed | ||
|
||
rm -f tmp/pids/server.pid | ||
|
||
bin/rails s -p $RAILS_PORT -b 0.0.0.0 |
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,6 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
gh secret set CLOUD_RUN_PROJECT --body "${CLOUD_RUN_PROJECT}" | ||
gh secret set CLOUD_RUN_REGION --body "${CLOUD_RUN_REGION}" | ||
gh secret set GCP_SERVICE_ACCOUNT_CREDENTIALS < /opt/credentials/cloud_run_creds.json |