-
Notifications
You must be signed in to change notification settings - Fork 4
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 #169 from kmc-jp/container
Build container image on push
- Loading branch information
Showing
8 changed files
with
104 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tmp/ | ||
node_modules/ | ||
vendor/ | ||
.bundle/ | ||
.git/ | ||
|
||
Dockerfile* |
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,48 +1,59 @@ | ||
name: Test | ||
name: Test & Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.2' | ||
- uses: actions/setup-node@v1 | ||
ruby-version: .ruby-version | ||
bundler-cache: true | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '14' | ||
- uses: actions/cache@v1 | ||
with: | ||
path: vendor/bundle | ||
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-gem- | ||
- uses: actions/cache@v1 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-npm- | ||
- name: bundle install | ||
node-version: lts/* | ||
cache: npm | ||
- name: Install npm modules | ||
run: | | ||
bundle config set path vendor/bundle | ||
bundle config set deployment true | ||
bundle install -j3 | ||
- name: npm install | ||
run: | | ||
npm install | ||
npm ci | ||
- name: Copy config | ||
run: | | ||
sed 's/development:/production:/' config/guildbook.yml.example > config/guildbook.yml | ||
- name: Build | ||
- name: Build assets | ||
run: | | ||
npm run build | ||
- name: Test | ||
run: | | ||
bundle exec rspec | ||
build: | ||
needs: | ||
- test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: meta | ||
name: Docker meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository_owner }}/guildbook | ||
tags: | | ||
type=raw,value={{sha}}-{{date 'YYYYMMDDHHmmss'}} | ||
- uses: docker/setup-buildx-action@v3 | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ github.token }} | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} | ||
tags: ${{ steps.meta.output.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 @@ | ||
3.2 |
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,42 @@ | ||
ARG RUBY=public.ecr.aws/sorah/ruby:3.2-bookworm | ||
ARG RUBYDEV=public.ecr.aws/sorah/ruby:3.2-dev-bookworm | ||
ARG NODE=public.ecr.aws/docker/library/node:lts-bookworm-slim | ||
|
||
### | ||
FROM $RUBYDEV as bundle | ||
|
||
WORKDIR /app | ||
COPY Gemfile Gemfile.lock . | ||
RUN bundle config set --local deployment true && \ | ||
bundle config set --local without test:development | ||
RUN --mount=type=cache,target=/tmp/bundler-cache \ | ||
BUNDLE_GLOBAL_GEM_CACHE=/tmp/bundler-cache \ | ||
bundle install --retry=3 | ||
|
||
### | ||
FROM $NODE as webpack | ||
|
||
WORKDIR /app | ||
COPY package.json package-lock.json . | ||
RUN --mount=type=cache,target=/root/.npm \ | ||
npm ci | ||
|
||
COPY . . | ||
|
||
RUN npm run build | ||
|
||
### | ||
FROM $RUBY | ||
|
||
RUN apt-get update -qq && \ | ||
apt-get install -y dumb-init && \ | ||
rm -rf /var/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
COPY --from=bundle /app/vendor /app/vendor | ||
COPY --from=bundle /app/.bundle /app/.bundle | ||
COPY --from=webpack /app/node_modules /app/node_modules | ||
|
||
ENTRYPOINT ["/app/docker/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
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,6 @@ | ||
#!/bin/dumb-init bash | ||
|
||
set -eo pipefail | ||
|
||
cd /app | ||
exec bundle exec unicorn "$@" |
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