Skip to content
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

deployment #20

Merged
merged 9 commits into from
Dec 18, 2024
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
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "next/core-web-vitals"
"extends": "next/core-web-vitals",
"rules": { "react-hooks/exhaustive-deps": "warn" }
}
24 changes: 20 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ on:
push:
branches:
- prod
pull_request:
branches:
- prod
- main

jobs:
next-build:
Expand Down Expand Up @@ -52,9 +50,10 @@ jobs:
rm -rf .env

ghcr-push:
needs: next-build # Job depends on next-build(above) job
needs: next-build
runs-on: ubuntu-latest
steps:
# Deploy to Production server
- name: Deploy on Production server
if: github.ref == 'refs/heads/prod'
uses: appleboy/[email protected]
Expand All @@ -70,3 +69,20 @@ jobs:
echo ${{ secrets.GHCR_TOKEN }} | sudo docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo docker pull ghcr.io/myriadflow/webxr:prod
sudo docker run --name="webxr" -p 8080:3000 -d ghcr.io/myriadflow/webxr:prod

# Deploy to Development server
- name: Deploy on Development server
if: github.ref == 'refs/heads/main'
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_REMOTE_SERVER_ADDRESS }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.DEV_REMOTE_SERVER_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
pwd
cd ~
sudo docker stop webxr && sudo docker rm webxr && sudo docker rmi ghcr.io/myriadflow/webxr:main
echo ${{ secrets.GHCR_TOKEN }} | sudo docker login ghcr.io -u ${{ secrets.GHCR_USERNAME }} --password-stdin
sudo docker pull ghcr.io/myriadflow/webxr:main
sudo docker run --name="webxr" -p 8080:3000 -d ghcr.io/myriadflow/webxr:main
Binary file modified .yarn/install-state.gz
Binary file not shown.
File renamed without changes.
52 changes: 52 additions & 0 deletions docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Docker Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the code from the repository
- name: Checkout repository
uses: actions/checkout@v2

# Step 2: Set up Node.js and install Yarn
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Yarn
run: corepack enable && corepack prepare yarn@stable --activate

# Step 3: Install dependencies and build the Next.js app
- name: Install dependencies
run: yarn install
- name: Build Next.js app
run: yarn build

# Step 4: Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Step 5: Build Docker image
- name: Build Docker image
run: docker build -t webxr .

# Step 6: Test the Docker container
- name: Run Docker container
run: docker run -d -p 3000:3000 --name webxr webxr
- name: Test if container is running
run: |
sleep 5 # Wait for the container to start
curl -f http://localhost:3000 || exit 1

# Step 7: Cleanup
- name: Stop and remove Docker container
run: docker stop webxr && docker rm webxr
4 changes: 3 additions & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM node:18-alpine AS deps

# Install libc6-compat if needed
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache libc6-compat python3 make g++

WORKDIR /app

Expand All @@ -12,6 +12,8 @@ COPY package.json yarn.lock ./
# Install dependencies with yarn
RUN yarn install

RUN yarn cache clean

# Rebuild the source code only when needed
FROM node:18-alpine AS builder
WORKDIR /app
Expand Down
Loading
Loading