Skip to content

Commit

Permalink
Merge pull request #3343 from dev-hato/add_watch
Browse files Browse the repository at this point in the history
開発環境: ファイルに変更が加えられたらDockerイメージを再ビルドする
  • Loading branch information
massongit authored Oct 17, 2023
2 parents 9e28f2d + 99e1c36 commit 046e2c5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-hato-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,dev.docker-compose.yml
files: docker-compose.yml,dev.base.docker-compose.yml
- run: echo 'TAG_NAME=latest' >> "$GITHUB_ENV"
if: ${{ github.event_name == 'release' }}
- name: Build and push (build) (latest)
Expand All @@ -94,7 +94,7 @@ jobs:
DOCKER_CONTENT_TRUST: 1
with:
push: true
files: docker-compose.yml,dev.docker-compose.yml
files: docker-compose.yml,dev.base.docker-compose.yml
- name: Start docker
env:
DOCKER_CONTENT_TRUST: 1
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@

```sh
export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g")
docker compose -f docker-compose.yml -f dev.docker-compose.yml up -d --wait
docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml build
docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml watch
```

7. コードの変更はdocker composeの再起動で適用できます。
Expand All @@ -87,12 +88,7 @@
docker compose restart
```

開発時は代わりに次のコマンドを実行します。

```sh
export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g")
docker compose -f docker-compose.yml -f dev.docker-compose.yml restart
```
開発時は自動的にDockerイメージの再ビルドが行われ反映されます。

#### lintをかける方法

Expand Down
10 changes: 3 additions & 7 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@

```sh
export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g")
docker compose -f docker-compose.yml -f dev.docker-compose.yml up -d --wait
docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml build
docker compose -f docker-compose.yml -f dev.base.docker-compose.yml -f dev.docker-compose.yml watch
```

7. コードの変更はdocker composeの再起動で適用できます。
Expand All @@ -87,12 +88,7 @@
docker compose restart
```

開発時は代わりに次のコマンドを実行します。

```sh
export TAG_NAME=$(git symbolic-ref --short HEAD | sed -e "s:/:-:g")
docker compose -f docker-compose.yml -f dev.docker-compose.yml restart
```
開発時は自動的にDockerイメージの再ビルドが行われ反映されます。

#### lintをかける方法

Expand Down
13 changes: 13 additions & 0 deletions dev.base.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: "3.8"
services:
hato-bot:
build:
cache_from:
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev:${TAG_NAME}
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/commit-hash:${TAG_NAME}
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/commit-hash
args:
- ENV=dev
image: ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev:${TAG_NAME}
62 changes: 49 additions & 13 deletions dev.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
---
version: "3.8"
services:
postgres:
develop:
watch:
- action: rebuild
path: ./docker-compose.yml
- action: rebuild
path: ./dev.base.docker-compose.yml
- action: rebuild
path: ./dev.docker-compose.yml
- action: rebuild
path: ./postgres/Dockerfile
hato-bot:
build:
cache_from:
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev:${TAG_NAME}
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/commit-hash:${TAG_NAME}
- ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/commit-hash
args:
- ENV=dev
image: ghcr.io/${REPOSITORY:-dev-hato/hato-bot}/hato-bot-dev:${TAG_NAME}
volumes:
- type: bind
source: .
target: /usr/src/app
develop:
watch:
- action: rebuild
path: ./docker-compose.yml
- action: rebuild
path: ./dev.base.docker-compose.yml
- action: rebuild
path: ./dev.docker-compose.yml
- action: rebuild
path: ./Dockerfile
- action: rebuild
path: ./slackbot_settings.py
- action: rebuild
path: ./Pipfile
- action: rebuild
path: ./package.json
- action: rebuild
path: ./package-lock.json
- action: rebuild
path: ./create_env.py
- action: rebuild
path: ./entrypoint.py
- action: rebuild
path: ./post_command.py
- action: rebuild
path: ./run.py
- action: rebuild
path: ./wait_db.py
- action: rebuild
path: ./library
- action: rebuild
path: ./plugins
- action: rebuild
path: ./postgres/docker-entrypoint-initdb.d
- action: rebuild
path: ./.textlintrc
- action: rebuild
path: ./commands.txt

0 comments on commit 046e2c5

Please sign in to comment.