Skip to content

Commit

Permalink
Merge pull request #9 from mizanmahi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mizanmahi authored Oct 7, 2024
2 parents 36f7bd3 + 869e286 commit d45775a
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ NODE_ENV="development"
PORT=5000

# DATABASE_URL="postgresql://postgres:123456@localhost:5432/mydb?blogdb=public"
# DATABASE_URL=postgresql://postgres:nextblogrds@db-nextblog.c72qycyeiylo.ap-southeast-1.rds.amazonaws.com:5432/nextblog -> aws rds
DATABASE_URL="your database url"


Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Build, Push, and Deploy Docker Image to EC2
on:
push:
branches:
- main # Trigger the workflow on push to the main branch
- main
- dev # Trigger the workflow on push to the dev branch

jobs:
build_and_deploy:
Expand All @@ -24,12 +25,12 @@ jobs:
# Step 3: Build the Docker image
- name: Build Docker image
run: |
docker build -t ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:3.0 .
docker build -t ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:7.0 .
# Step 4: Push Docker image to DockerHub
- name: Push Docker image
run: |
docker push ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:3.0
docker push ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:7.0
# Step 5: SSH to EC2 and deploy the Docker container
- name: Deploy to EC2
Expand All @@ -41,7 +42,7 @@ jobs:
port: 22
script: |
# Pull the latest image
sudo docker pull ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:3.0
sudo docker pull ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:7.0
# Check if the container is running and stop/remove it if it exists
if [ "$(sudo docker ps -a -q -f name=nextblog)" ]; then
Expand All @@ -57,4 +58,4 @@ jobs:
# Run the container
echo "Starting a new container..."
sudo docker run -d --name nextblog --env-file .env -p 9000:5000 ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:3.0
sudo docker run -d --name nextblog --env-file .env -p 9000:5000 ${{ secrets.DOCKERHUB_USER_NAME }}/nextblog:7.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules

.vercel

dist
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ COPY . .
EXPOSE 5000

# Define the command to run your application.
CMD ["sh", "-c", "npx prisma generate && npx prisma migrate deploy && yarn build && yarn start"]
CMD ["sh", "-c", "yarn migrate && yarn build && yarn start"]
5 changes: 5 additions & 0 deletions src/app/middlewares/globalErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ const globalErrorHandler = (
};

export default globalErrorHandler;





File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit d45775a

Please sign in to comment.