-
Notifications
You must be signed in to change notification settings - Fork 1
feat/mitomen/261/CI-CD-Pipeline #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 5 commits
17b3193
a905492
7c53aee
bcab84b
a6aecbb
3acc9ad
e799944
8d256a0
196cfc8
766ee94
ac32349
c95100f
0e23719
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: CD | ||
|
|
||
| on: | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: self-hosted | ||
| steps: | ||
| - name: SSH and Deploy | ||
| run: | | ||
| - name: Add deploy host key | ||
| run: | | ||
| mkdir -p ~/.ssh | ||
| ssh-keyscan -H "${{ secrets.CONTAINER_IP }}" >> ~/.ssh/known_hosts | ||
|
|
||
| - name: SSH and Deploy | ||
| run: | | ||
| ssh deploy-user@${{ secrets.CONTAINER_IP }} << 'EOF' | ||
| set -e | ||
| cd /home/deploy-user/SeeFT | ||
| echo '${{ secrets.HARBOR_PASS }}' | docker login '${{ secrets.HARBOR_REG }}' -u '${{ secrets.HARBOR_USERNAME }}' --password-stdin | ||
| docker compose -f docker-compose.cd.yml pull | ||
| docker compose -f docker-compose.cd.yml up -d | ||
|
FastDefence marked this conversation as resolved.
|
||
| docker image prune -f | ||
| EOF | ||
| set -e | ||
| cd /home/deploy-user/SeeFT | ||
| git fetch origin main | ||
| git reset --hard origin/main | ||
| echo '${{ secrets.HARBOR_PASS }}' | docker login '${{ secrets.HARBOR_REG }}' -u '${{ secrets.HARBOR_USERNAME }}' --password-stdin | ||
| docker compose -f docker-compose.cd.yml pull | ||
| docker compose -f docker-compose.cd.yml up -d | ||
| docker image prune -f | ||
| EOF | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_call: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| submodules: recursive | ||
| token: ${{ secrets.GH_PAT || github.token }} | ||
|
|
||
| - name: Connect to Tailscale | ||
| uses: tailscale/github-action@v2 | ||
| with: | ||
| oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }} | ||
| oauth-secret: ${{ secrets.TAILSCALE_OAUTH_CLIENT_SECRET }} | ||
| tags: tag:ci | ||
|
|
||
| - name: Configure Insecure Registry | ||
| run: | | ||
| sudo service docker stop | ||
| echo "{\"insecure-registries\": [\"${{ secrets.HARBOR_REG }}\"]}" | sudo tee /etc/docker/daemon.json | ||
| sudo service docker start | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| with: | ||
| driver-opts: network=host | ||
| config-inline: | | ||
| [registry."${{ secrets.HARBOR_REG }}"] | ||
| http = true | ||
| insecure = true | ||
|
FastDefence marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Log in to Harbor | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ secrets.HARBOR_REG }} | ||
| username: ${{ secrets.HARBOR_USERNAME }} | ||
| password: ${{ secrets.HARBOR_PASS }} | ||
|
|
||
| - name: Create .env file | ||
| run: | | ||
| mkdir -p mobile/env | ||
| echo "${{ secrets.SEEFT_MOBILE_ENVS }}" > mobile/env/.env | ||
|
FastDefence marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Build and Push API | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ./api | ||
| file: ./api/prod.Dockerfile | ||
| push: true | ||
| tags: ${{ secrets.HARBOR_REG }}/seeft/api:latest | ||
| cache-from: type=gha | ||
|
|
||
| - name: Build and Push Admin | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ./admin | ||
| file: ./admin/prod.Dockerfile | ||
| push: true | ||
| tags: ${{ secrets.HARBOR_REG }}/seeft/admin:latest | ||
| cache-from: type=gha | ||
|
|
||
| - name: Build and Push Mobile | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: ./mobile | ||
| file: ./mobile/Dockerfile | ||
| push: true | ||
| tags: ${{ secrets.HARBOR_REG }}/seeft/mobile:latest | ||
| cache-from: type=gha | ||
|
|
||
| trigger-cd: | ||
| needs: build-and-push | ||
| uses: ./.github/workflows/CD.yml | ||
| secrets: inherit | ||
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | |||||||||||||||||
| version: "3" | |||||||||||||||||
| services: | |||||||||||||||||
| cloudflare: | |||||||||||||||||
| image: "cloudflare/cloudflared:latest" | |||||||||||||||||
| container_name: "nutfes-seeft-web" | |||||||||||||||||
| volumes: ["./web/prod:/home/nonroot/.cloudflared"] | |||||||||||||||||
| command: tunnel run | |||||||||||||||||
|
|
|||||||||||||||||
| mobile: | |||||||||||||||||
| image: ${HARBOR_REG}/seeft/mobile:latest | |||||||||||||||||
| container_name: "nutfes-seeft-mobile" | |||||||||||||||||
| command: "python3 ./python/server.py" | |||||||||||||||||
| ports: ["45029:45029"] | |||||||||||||||||
| environment: | |||||||||||||||||
| NEXT_PUBLIC_APP_ENV: "production" | |||||||||||||||||
| depends_on: ["api"] | |||||||||||||||||
| restart: always | |||||||||||||||||
|
|
|||||||||||||||||
| api: | |||||||||||||||||
| image: ${HARBOR_REG}/seeft/api:latest | |||||||||||||||||
| container_name: "nutfes-seeft-api" | |||||||||||||||||
| volumes: ["./api:/env/app"] | |||||||||||||||||
| command: sh -c "go build -o main main.go && ./main" | |||||||||||||||||
|
Comment on lines
+22
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t compile Go at container startup in CD compose. Lines 22-23 bind-mount source and run Suggested direction api:
image: ${HARBOR_REG}/seeft/api:latest
container_name: "nutfes-seeft-api"
- volumes: ["./api:/env/app"]
- command: sh -c "go build -o main main.go && ./main"
+ # rely on the image artifact built in CI
+ # command should be provided by Dockerfile CMD/ENTRYPOINT
env_file: ["./api/env/seeft.env"]
ports: ["1234:1234"]
restart: always🤖 Prompt for AI AgentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
なぜ Dockerfile 内でビルドすべきか
|
|||||||||||||||||
| env_file: ["./api/env/seeft.env"] | |||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
|||||||||||||||||
| ports: ["1234:1234"] | |||||||||||||||||
| restart: always | |||||||||||||||||
|
|
|||||||||||||||||
| admin: | |||||||||||||||||
| image: ${HARBOR_REG}/seeft/admin:latest | |||||||||||||||||
| container_name: "nutfes-seeft-admin" | |||||||||||||||||
| command: sh -c "npm install && npm run build && npm run start" | |||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid runtime Line 31 makes startup dependent on live package install/build, increasing failure risk and startup time. Prefer running only the prebuilt app command from the image. 🤖 Prompt for AI AgentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 147 🏁 Script executed: Length of output: 283
現在の 以下のように # admin/prod.Dockerfile
FROM node:16.13.0
WORKDIR /app/next-project/seeft-admin
COPY ./ /app
ENV NEXT_PUBLIC_APP_ENV production
# ← ここでビルドまで完結させる
RUN npm ci && npm run build
CMD ["npm", "run", "start"]そして admin:
image: ${HARBOR_REG}/seeft/admin:latest
container_name: "nutfes-seeft-admin"
# command は不要(DockerfileのCMDが使われる)
ports: ["5000:3000"]
environment:
NEXT_PUBLIC_APP_ENV: "production"
stdin_open: true
tty: true
depends_on: ["api"]
restart: alwaysこの変更のメリット:
なお、 🧠 Learnings used |
|||||||||||||||||
| ports: | |||||||||||||||||
| - "5000:3000" | |||||||||||||||||
| environment: | |||||||||||||||||
| NEXT_PUBLIC_APP_ENV: "production" | |||||||||||||||||
| stdin_open: true | |||||||||||||||||
| tty: true | |||||||||||||||||
| depends_on: [api] | |||||||||||||||||
| restart: always | |||||||||||||||||
|
|
|||||||||||||||||
| networks: | |||||||||||||||||
| default: | |||||||||||||||||
| name: seeft-default | |||||||||||||||||
| external: true | |||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
|||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.