Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,22 @@ jobs:
script: |
set -e
cd ${MURUN_DEPLOY_DIR:-~/murun-peterabcd/deploy}
git -C .. fetch --depth=1 origin "${{ github.ref_name }}"
git -C .. checkout -B "${{ github.ref_name }}" FETCH_HEAD
export IMAGE_TAG="${{ needs.build.outputs.image_tag }}"
export MURUN_ENV_FILE=".env.${{ needs.build.outputs.target }}"
on_error() {
echo "::group::docker compose ps"
docker compose -p murun-${{ needs.build.outputs.target }} --env-file "$MURUN_ENV_FILE" ps || true
echo "::endgroup::"
echo "::group::app logs"
docker compose -p murun-${{ needs.build.outputs.target }} --env-file "$MURUN_ENV_FILE" logs --tail=160 app || true
echo "::endgroup::"
echo "::group::caddy logs"
docker compose -p murun-${{ needs.build.outputs.target }} --env-file "$MURUN_ENV_FILE" logs --tail=80 caddy || true
echo "::endgroup::"
}
trap on_error ERR
docker compose -p murun-${{ needs.build.outputs.target }} --env-file "$MURUN_ENV_FILE" pull
docker compose -p murun-${{ needs.build.outputs.target }} --env-file "$MURUN_ENV_FILE" up -d --remove-orphans
docker image prune -f
3 changes: 3 additions & 0 deletions app/api/health/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function GET() {
return Response.json({ ok: true });
}
7 changes: 3 additions & 4 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/public ./public

# Prisma: migration 적용에 필요한 CLI + schema + 이미 생성된 client
# Prisma migrate deploy 는 CLI 의 transitive deps(effect 등)가 필요하므로
# standalone trace 의 최소 node_modules 대신 builder 의 전체 install tree 를 사용한다.
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/prisma ./node_modules/prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/@prisma ./node_modules/@prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules

# Entrypoint: migrate deploy → node server.js
COPY --chown=nextjs:nodejs deploy/entrypoint.sh /app/entrypoint.sh
Expand Down
6 changes: 5 additions & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ services:
expose:
- "3000"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:3000/"]
test:
[
"CMD-SHELL",
"node -e \"fetch('http://127.0.0.1:3000/api/health').then((r) => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))\"",
]
interval: 30s
timeout: 5s
retries: 5
Expand Down
2 changes: 1 addition & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export default auth((req) => {

export const config = {
matcher: [
"/((?!api/auth|_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml|.*\\.(?:png|jpg|jpeg|gif|svg|webp|avif|ico)).*)",
"/((?!api/auth|api/health|_next/static|_next/image|favicon.ico|robots.txt|sitemap.xml|.*\\.(?:png|jpg|jpeg|gif|svg|webp|avif|ico)).*)",
],
};
Loading