Skip to content

Commit

Permalink
added ci-cd workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GokuxSS4 committed Jan 6, 2025
1 parent a34d702 commit 5772e70
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 47 deletions.
7 changes: 4 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Dockerfile
.dockerignore
node_modules
README.md
.next
.git
.vscode
.github
.github
Dockerfile*
docker-compose.yaml
.dockerignore
56 changes: 56 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 0 additions & 22 deletions .github/workflows/lint_and_format.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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.
30 changes: 30 additions & 0 deletions infra/k8s/app/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions infra/k8s/app/services.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions infra/k8s/hls-proxy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions infra/k8s/hls-proxy/services.yaml
Original file line number Diff line number Diff line change
@@ -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
Empty file added infra/k8s/ingress.yaml
Empty file.
20 changes: 20 additions & 0 deletions infra/k8s/redis/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions infra/k8s/redis/services.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions infra/k8s/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: ghcr-secret
namespace: default
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: ewoJImF1dGhzIjogewoJCSJnaGNyLmlvIjoge30sCgkJImh0dHBzOi8vaW5kZXguZG9ja2VyLmlvL3YxLyI6IHt9Cgl9LAoJImNyZWRzU3RvcmUiOiAiZGVza3RvcCIsCgkiY3VycmVudENvbnRleHQiOiAiZGVmYXVsdCIsCgkicGx1Z2lucyI6IHsKCQkiLXgtY2xpLWhpbnRzIjogewoJCQkiZW5hYmxlZCI6ICJ0cnVlIgoJCX0KCX0KfQ==

0 comments on commit 5772e70

Please sign in to comment.