Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
feat: dockerサポート (#142)
Browse files Browse the repository at this point in the history
* feat: dockerサポート

* ci: fix shellcheck
  • Loading branch information
book000 authored Sep 21, 2022
1 parent eb5a84f commit f21be45
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 58 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Actionlint with reviewdog

on:
push:
branches:
- main
- master
pull_request:

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Run ationlint (Push)
if: ${{ github.event_name == 'push' }}
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color
- name: Run actionlint (Pull-request)
if: ${{ github.event_name == 'pull_request' }}
uses: reviewdog/action-actionlint@v1
with:
fail_on_error: true
52 changes: 0 additions & 52 deletions .github/workflows/ci.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 任意のレジストリに Docker image を公開orビルドする。
# master/mainのプッシュ時、プルリクの作成・更新時、リリース時に動作する。

name: Docker

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
release:
types:
- published

env:
REGISTRY: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: ${{ github.repository }}
PLATFORMS: linux/amd64,linux/arm64

jobs:
job:
name: Docker build
runs-on: ubuntu-latest

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to ${{ env.REGISTRY }}
if: github.event_name == 'release'
uses: docker/login-action@v2.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v3.1.1
with:
context: .
push: ${{ github.event_name == 'release' }}
platforms: ${{ env.PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
12 changes: 6 additions & 6 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
- name: 📃 Check package.json definition
id: package-json
run: |
compile=$(cat package.json | jq '.scripts | has("compile")')
build=$(cat package.json | jq '.scripts | has("build")')
generate=$(cat package.json | jq '.scripts | has("generate")')
package=$(cat package.json | jq '.scripts | has("package")')
lint=$(cat package.json | jq '.scripts | has("lint")')
test=$(cat package.json | jq '.scripts | has("test")')
compile=$(jq '.scripts | has("compile")' package.json)
build=$(jq '.scripts | has("build")' package.json)
generate=$(jq '.scripts | has("generate")' package.json)
package=$(jq '.scripts | has("package")' package.json)
lint=$(jq '.scripts | has("lint")' package.json)
test=$(jq '.scripts | has("test")' package.json)
echo "compile: $compile"
echo "build: $build"
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:16 as builder

WORKDIR /app

COPY package.json .
COPY yarn.lock .
RUN yarn install && \
yarn cache clean

COPY src/ src/
COPY tsconfig.json .

COPY entrypoint.sh .

ENTRYPOINT [ "/app/entrypoint.sh" ]
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.8'

services:
app:
build: .
# image: ghcr.io/jaoafa/jaotanChatLogger3:latest
volumes:
- type: bind
source: ./config/
target: /app/config/
init: true
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

while :
do
yarn build || true
done

0 comments on commit f21be45

Please sign in to comment.