From 4b6642b77e72360d3b7b075cc3188e22fa09fdf9 Mon Sep 17 00:00:00 2001 From: Pugma Date: Sat, 22 Jun 2024 14:09:24 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ui=E5=90=8C=E6=A7=98=E3=81=ABAPI=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=81=AE=E8=87=AA=E5=8B=95=E7=94=9F=E6=88=90=E9=83=A8?= =?UTF-8?q?=E5=88=86=E3=82=84=E8=A8=98=E6=B3=95=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 42 +++++++++++++++++++++++++--------- .github/workflows/release.yaml | 30 ++++++++++++++++++++++++ .github/workflows/staging.yml | 23 ++++++++++++++++++- 3 files changed, 83 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8ceb11c..4c8e338b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: CI on: push: branches: - - 'master' + - 'main' pull_request: jobs: @@ -16,7 +16,9 @@ jobs: with: node-version-file: .node-version cache: npm - - run: SKIP_GENAPI=1 npm ci + - run: npm ci + env: + SKIP_GENAPI: 1 genApi: name: Generate APIs runs-on: ubuntu-latest @@ -34,14 +36,18 @@ jobs: build: name: Build runs-on: ubuntu-latest - needs: [packages, genApi] + needs: + - packages + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: npm - - run: SKIP_GENAPI=1 npm ci + - run: npm ci + env: + SKIP_GENAPI: 1 - uses: actions/download-artifact@v4 with: name: apis @@ -52,14 +58,18 @@ jobs: lint: name: Lint runs-on: ubuntu-latest - needs: [packages, genApi] + needs: + - packages + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: npm - - run: SKIP_GENAPI=1 npm ci + - run: npm ci + env: + SKIP_GENAPI: 1 - uses: actions/download-artifact@v4 with: name: apis @@ -68,14 +78,18 @@ jobs: format: name: Format runs-on: ubuntu-latest - needs: [packages, genApi] + needs: + - packages + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: npm - - run: SKIP_GENAPI=1 npm ci + - run: npm ci + env: + SKIP_GENAPI: 1 - uses: actions/download-artifact@v4 with: name: apis @@ -84,14 +98,18 @@ jobs: typeCheck: name: Type Check runs-on: ubuntu-latest - needs: [packages, genApi] + needs: + - packages + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: .node-version cache: npm - - run: SKIP_GENAPI=1 npm ci + - run: npm ci + env: + SKIP_GENAPI: 1 - uses: actions/download-artifact@v4 with: name: apis @@ -100,7 +118,9 @@ jobs: test: name: Test runs-on: ubuntu-latest - needs: [packages, genApi] + needs: + - packages + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 91241c80..1b5b19ee 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,9 +12,27 @@ env: IMAGE_NAME: traportfolio-dashboard jobs: + # API生成部分をDockerのビルド部分から分離 + genApi: + name: Generate APIs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: npm + - run: npm ci + - uses: actions/upload-artifact@v4 + with: + name: apis + path: ./src/lib/apis/generated + # GitHubリリース機能で自動リリース make-dist: runs-on: ubuntu-latest + needs: + - genApi steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -23,6 +41,10 @@ jobs: cache: npm - name: Node package install run: npm ci + - uses: actions/download-artifact@v4 + with: + name: apis + path: ./src/lib/apis/generated - name: Vite build run: npm run build env: @@ -40,6 +62,9 @@ jobs: # ghcrにビルド済みイメージをアップロード image: name: Build Docker Image + needs: + - genApi + - make-dist runs-on: ubuntu-latest steps: - name: Set IMAGE_TAG env @@ -61,6 +86,11 @@ jobs: username: traptitech password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/download-artifact@v4 + with: + name: apis + path: ./src/lib/apis/generated + - name: Build and push uses: docker/build-push-action@v5 with: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 2e330f5d..e81d10c3 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -10,11 +10,27 @@ env: IMAGE_TAG: main jobs: + genApi: + name: Generate APIs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version-file: .node-version + cache: npm + - run: npm ci + - uses: actions/upload-artifact@v4 + with: + name: apis + path: ./src/lib/apis/generated image: permissions: contents: read packages: write runs-on: ubuntu-latest + needs: + - genApi steps: - name: Login to GitHub Container Registry uses: docker/login-action@v3 @@ -23,6 +39,10 @@ jobs: username: traptitech password: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: apis + path: ./src/lib/apis/generated - name: Build and push uses: docker/build-push-action@v5 with: @@ -33,7 +53,8 @@ jobs: deploy-staging: name: Deploy staging runs-on: ubuntu-latest - needs: [image] + needs: + - image steps: - name: Install SSH key uses: shimataro/ssh-key-action@v2 From 3b29e549f1f2c85239922f0b8ad5a1c1d93b171b Mon Sep 17 00:00:00 2001 From: Pugma Date: Sat, 22 Jun 2024 16:19:31 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Dockerfile=E3=82=82=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f7397e4..8384073d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ -FROM --platform=$BUILDPLATFORM node:20.8.0-alpine as build +FROM --platform=$BUILDPLATFORM node:20.11.1-alpine as build WORKDIR /app -RUN apk update \ - && apk --no-cache add openjdk11 \ - && rm -rf /var/cache/apk/* +RUN apk update + +ENV NODE_ENV=production SKIP_GENAPI=1 COPY package.json package-lock.json ./ COPY scripts/ ./scripts/ RUN npm ci COPY . . -RUN NODE_ENV=production npm run build +RUN npm run build # 本番環境 FROM caddy:2.4.6-alpine