Skip to content

Commit

Permalink
dockerized and added deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
borgaar committed Jan 9, 2025
1 parent cec2c7b commit c017207
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy

on:
push:
branches: ["devops(dockerfile)/dev"]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
concurrency:
group: deployment_lock
cancel-in-progress: false
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.KEY }}" > ~/.ssh/key
chmod 600 ~/.ssh/key
ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: Create .env file
run: |
echo 'DATABASE_URL="${{ secrets.DATABASE_URL }}"' >> .env
echo 'NEXTAUTH_URL="${{ secrets.NEXTAUTH_URL }}"' >> .env
echo 'NEXT_PUBLIC_LEPTON_API_URL="${{ secrets.NEXT_PUBLIC_LEPTON_API_URL }}"' >> .env
echo 'ALLOWED_GROUP_SLUGS="${{ secrets.ALLOWED_GROUP_SLUGS }}"' >> .env
echo 'NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}"' >> .env
- name: Copy .env to VPS
run: |
scp -v -i ~/.ssh/key .env ${{ secrets.USER }}@${{ secrets.HOST }}:${{ secrets.PATH }}
- name: Deploy to VPS
run: |
ssh -v -i ~/.ssh/key ${{ secrets.USER }}@${{ secrets.HOST }} << 'ENDSSH'
cd ${{ secrets.PATH }}
chmod 0600 .env
git pull
make prod
ENDSSH
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
.PHONY: db
db:
docker compose up -d

.PHONY: prod
prod:
- docker container stop blitzed
- docker container rm blitzed
- docker image rm blitzed
docker build -t blitzed:latest .
prisma migrate deploy
docker run --env-file .env -p 4000:3000 --name blitzed -d blitzed:latest
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {};
const config = {
output: "standalone",
};

export default config;
5 changes: 0 additions & 5 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ generator client {
provider = "prisma-client-js"
}

generator erDiagram {
provider = "prisma-erd-generator"
output = "../ER_diagram.pdf"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
Expand Down

0 comments on commit c017207

Please sign in to comment.