feature/syasya/testlayout #8
							
								
								
									
										59
									
								
								.gitea/workflows/deploy.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								.gitea/workflows/deploy.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,59 @@
 | 
			
		||||
name: Build and Deploy
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    tags:
 | 
			
		||||
      - 'v*'
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build-and-deploy:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout Code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
 | 
			
		||||
      - name: Extract Tag Name
 | 
			
		||||
        id: extract_tag
 | 
			
		||||
        run: |
 | 
			
		||||
          TAG_NAME=${GITHUB_REF#refs/tags/}
 | 
			
		||||
          echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
 | 
			
		||||
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v3
 | 
			
		||||
 | 
			
		||||
      - name: Login to Docker Hub
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKERHUB_USERNAME }}
 | 
			
		||||
          password: ${{ secrets.DOCKERHUB_PASSWORD }}
 | 
			
		||||
 | 
			
		||||
      - name: Build and Push Docker Image
 | 
			
		||||
        uses: docker/build-push-action@v5
 | 
			
		||||
        with:
 | 
			
		||||
          context: .
 | 
			
		||||
          file: ./Dockerfile
 | 
			
		||||
          push: true
 | 
			
		||||
          tags: |
 | 
			
		||||
            rooftopenergy/rooftop_dpmdashboard:${{ steps.extract_tag.outputs.tag }}
 | 
			
		||||
          
 | 
			
		||||
      - name: Install sshpass
 | 
			
		||||
        run: sudo apt-get update && sudo apt-get install -y sshpass
 | 
			
		||||
 | 
			
		||||
      - name: Deploy to VPS
 | 
			
		||||
        env:
 | 
			
		||||
          SSHPASS: ${{ secrets.VPS_PASSWORD }}
 | 
			
		||||
        run: |
 | 
			
		||||
          sshpass -e ssh -o StrictHostKeyChecking=no ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} << EOF
 | 
			
		||||
            set -e
 | 
			
		||||
 | 
			
		||||
            echo "Using tag: ${{ steps.extract_tag.outputs.tag }}"
 | 
			
		||||
 | 
			
		||||
            cd /root/UserDashboard
 | 
			
		||||
 | 
			
		||||
            sed -i "s|rooftopenergy/rooftop_dpmdashboard:.*|rooftopenergy/rooftop_dpmdashboard:${{ steps.extract_tag.outputs.tag }}|g" docker-compose.yml
 | 
			
		||||
 | 
			
		||||
            docker compose down
 | 
			
		||||
            docker compose pull
 | 
			
		||||
            docker compose up -d
 | 
			
		||||
          EOF
 | 
			
		||||
							
								
								
									
										26
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
FROM node:18
 | 
			
		||||
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
COPY . .
 | 
			
		||||
 | 
			
		||||
# Accept build-time arguments
 | 
			
		||||
ARG FASTAPI_URL
 | 
			
		||||
ARG INTERNAL_API_BASE_URL
 | 
			
		||||
ARG DATABASE_URL
 | 
			
		||||
ARG JWT_SECRET
 | 
			
		||||
 | 
			
		||||
# Assign them to environment variables inside the image
 | 
			
		||||
ENV FASTAPI_URL=$FASTAPI_URL
 | 
			
		||||
ENV INTERNAL_API_BASE_URL=$INTERNAL_API_BASE_URL
 | 
			
		||||
ENV DATABASE_URL=$DATABASE_URL
 | 
			
		||||
ENV JWT_SECRET=$JWT_SECRET
 | 
			
		||||
 | 
			
		||||
RUN npm install --force
 | 
			
		||||
 | 
			
		||||
# Build Next.js app
 | 
			
		||||
RUN npx prisma generate
 | 
			
		||||
RUN npm run build
 | 
			
		||||
 | 
			
		||||
EXPOSE 3005 
 | 
			
		||||
 | 
			
		||||
CMD ["npm", "start"]
 | 
			
		||||
							
								
								
									
										18
									
								
								prisma/migrations/20250815012144_init_users/migration.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								prisma/migrations/20250815012144_init_users/migration.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
			
		||||
/*
 | 
			
		||||
  Warnings:
 | 
			
		||||
 | 
			
		||||
  - You are about to drop the `EnergyData` table. If the table is not empty, all the data it contains will be lost.
 | 
			
		||||
  - You are about to drop the `Site` table. If the table is not empty, all the data it contains will be lost.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
-- DropForeignKey
 | 
			
		||||
ALTER TABLE "public"."EnergyData" DROP CONSTRAINT "EnergyData_consumptionSiteId_fkey";
 | 
			
		||||
 | 
			
		||||
-- DropForeignKey
 | 
			
		||||
ALTER TABLE "public"."EnergyData" DROP CONSTRAINT "EnergyData_generationSiteId_fkey";
 | 
			
		||||
 | 
			
		||||
-- DropTable
 | 
			
		||||
DROP TABLE "public"."EnergyData";
 | 
			
		||||
 | 
			
		||||
-- DropTable
 | 
			
		||||
DROP TABLE "public"."Site";
 | 
			
		||||
@ -0,0 +1,12 @@
 | 
			
		||||
/*
 | 
			
		||||
  Warnings:
 | 
			
		||||
 | 
			
		||||
  - You are about to drop the column `password` on the `User` table. All the data in the column will be lost.
 | 
			
		||||
  - Added the required column `passwordHash` to the `User` table without a default value. This is not possible if the table is not empty.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "public"."User" DROP COLUMN "password",
 | 
			
		||||
ADD COLUMN     "name" TEXT,
 | 
			
		||||
ADD COLUMN     "passwordHash" TEXT NOT NULL,
 | 
			
		||||
ADD COLUMN     "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
 | 
			
		||||
							
								
								
									
										14
									
								
								prisma/migrations/20250815022446_add_user/migration.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								prisma/migrations/20250815022446_add_user/migration.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
/*
 | 
			
		||||
  Warnings:
 | 
			
		||||
 | 
			
		||||
  - You are about to drop the column `name` on the `User` table. All the data in the column will be lost.
 | 
			
		||||
  - You are about to drop the column `passwordHash` on the `User` table. All the data in the column will be lost.
 | 
			
		||||
  - You are about to drop the column `updatedAt` on the `User` table. All the data in the column will be lost.
 | 
			
		||||
  - Added the required column `password` to the `User` table without a default value. This is not possible if the table is not empty.
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
-- AlterTable
 | 
			
		||||
ALTER TABLE "public"."User" DROP COLUMN "name",
 | 
			
		||||
DROP COLUMN "passwordHash",
 | 
			
		||||
DROP COLUMN "updatedAt",
 | 
			
		||||
ADD COLUMN     "password" TEXT NOT NULL;
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user