diff --git a/.dockerignore b/.dockerignore index 2b46aa7..84bbda1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,9 @@ -Dockerfile -.dockerignore node_modules README.md .next .git .vscode -.github \ No newline at end of file +.github +Dockerfile* +docker-compose.yaml +.dockerignore \ No newline at end of file diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml new file mode 100644 index 0000000..c84cd77 --- /dev/null +++ b/.github/workflows/ci-cd.yaml @@ -0,0 +1,56 @@ +name: CI/CD Workflow + +on: + pull_request: + branches: + - "**" + push: + branches: + - dev + - main + +jobs: + linting-and-formatting: + name: Perform linting and formatting checks + runs-on: ubuntu-latest + steps: + - name: Checkout the Repository + uses: actions/checkout@v3 + + - name: Install Dependencies + run: npm install + + - name: Run linting check + run: npm run lint:check + + - name: Check formatting + run: npm run format:check + + build-and-deploy: + name: Build and Deploy Application + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.REPO_TOKEN }} + + - name: Build and Push app.prod Image + run: | + REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') + REPO_NAME_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') + docker build -f Dockerfile.app.prod -t ghcr.io/$REPO_NAME_LOWER/app-prod:latest . + docker push ghcr.io/$REPO_NAME_LOWER/app-prod:latest + + - name: Build and Push hls_proxy Image + run: | + REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') + REPO_NAME_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') + docker build -f Dockerfile.hls_proxy -t ghcr.io/$REPO_NAME_LOWER/hls-proxy:latest . + docker push ghcr.io/$REPO_NAME_LOWER/hls-proxy:latest diff --git a/.github/workflows/lint_and_format.yaml b/.github/workflows/lint_and_format.yaml deleted file mode 100644 index 5514c0f..0000000 --- a/.github/workflows/lint_and_format.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Linting and formatting on PR -on: - pull_request: - branches: - - "**" - -jobs: - Continuous-Integration: - name: Performs linting, formatting on the application - runs-on: ubuntu-latest - steps: - - name: Checkout the Repository - uses: actions/checkout@v3 - - - name: Install Dependencies - run: npm install - - - name: Run linting check - run: npm run lint:check - - - name: Check formatting - run: npm run format:check diff --git a/README.md b/README.md index e215bc4..2033599 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). - ## Getting Started First, run the development server: @@ -14,23 +12,3 @@ pnpm dev bun dev ``` -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. - -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. - -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - -## Learn More - -To learn more about Next.js, take a look at the following resources: - -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. - -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Deploy on Vercel - -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. - -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/infra/k8s/app/deployment.yaml b/infra/k8s/app/deployment.yaml new file mode 100644 index 0000000..6e1430d --- /dev/null +++ b/infra/k8s/app/deployment.yaml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: app-aniweeb-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: aniweeb-app + template: + metadata: + labels: + app: aniweeb-app + spec: + containers: + - name: aniweeb-app-container + image: ghcr.io/gokuxss4/aniweeb/app-prod:latest + ports: + - containerPort: 3000 + env: + - name: REDIS_HOST + value: "redis-service" + - name: REDIS_PORT + value: "6379" + - name: HLS_PROXY_HOST + value: "hls-proxy-service" + - name: HLS_PROXY_PORT + value: "8080" + imagePullSecrets: + - name: ghcr-secret \ No newline at end of file diff --git a/infra/k8s/app/services.yaml b/infra/k8s/app/services.yaml new file mode 100644 index 0000000..707ad3e --- /dev/null +++ b/infra/k8s/app/services.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: app-aniweeb-service +spec: + selector: + app: aniweeb-app + ports: + - protocol: TCP + port: 80 + targetPort: 3000 + nodePort: 30007 + type: NodePort \ No newline at end of file diff --git a/infra/k8s/hls-proxy/deployment.yaml b/infra/k8s/hls-proxy/deployment.yaml new file mode 100644 index 0000000..d0f59b8 --- /dev/null +++ b/infra/k8s/hls-proxy/deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hls-proxy-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: hls-proxy + template: + metadata: + labels: + app: hls-proxy + spec: + containers: + - name: hls-proxy-container + image: ghcr.io/gokuxss4/aniweeb/hls-proxy:latest + ports: + - containerPort: 8080 + imagePullSecrets: + - name: ghcr-secret diff --git a/infra/k8s/hls-proxy/services.yaml b/infra/k8s/hls-proxy/services.yaml new file mode 100644 index 0000000..74e4077 --- /dev/null +++ b/infra/k8s/hls-proxy/services.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: hls-proxy-service +spec: + selector: + app: hls-proxy + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + nodePort: 30008 + type: NodePort \ No newline at end of file diff --git a/infra/k8s/ingress.yaml b/infra/k8s/ingress.yaml new file mode 100644 index 0000000..e69de29 diff --git a/infra/k8s/redis/deployment.yaml b/infra/k8s/redis/deployment.yaml new file mode 100644 index 0000000..1bcf31f --- /dev/null +++ b/infra/k8s/redis/deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: redis-deployment +spec: + replicas: 2 + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + containers: + - name: redis-container + image: redis:latest + ports: + - containerPort: 6379 + command: ["redis-server", "--appendonly", "yes"] diff --git a/infra/k8s/redis/services.yaml b/infra/k8s/redis/services.yaml new file mode 100644 index 0000000..9795b19 --- /dev/null +++ b/infra/k8s/redis/services.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis-service +spec: + selector: + app: redis + ports: + - protocol: TCP + port: 6379 + targetPort: 6379 + type: ClusterIP \ No newline at end of file diff --git a/infra/k8s/secrets.yaml b/infra/k8s/secrets.yaml new file mode 100644 index 0000000..f1b7866 --- /dev/null +++ b/infra/k8s/secrets.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: ghcr-secret + namespace: default +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: ewoJImF1dGhzIjogewoJCSJnaGNyLmlvIjoge30sCgkJImh0dHBzOi8vaW5kZXguZG9ja2VyLmlvL3YxLyI6IHt9Cgl9LAoJImNyZWRzU3RvcmUiOiAiZGVza3RvcCIsCgkiY3VycmVudENvbnRleHQiOiAiZGVmYXVsdCIsCgkicGx1Z2lucyI6IHsKCQkiLXgtY2xpLWhpbnRzIjogewoJCQkiZW5hYmxlZCI6ICJ0cnVlIgoJCX0KCX0KfQ== \ No newline at end of file