Skip to content

Commit

Permalink
Merge pull request #41 from imdeveshshukla/deploy
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
imdeveshshukla authored Aug 17, 2024
2 parents e94a472 + 49b4bbe commit 4a5d9c7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ jobs:
- name: Verify Pushed Image
run: docker pull imdeveshshukla/quiet-backend

# - name: Deploy to EC2
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_KEY }}
# script: |
# sudo docker pull imdeveshshukla/quiet-backend:latest
# sudo docker stop web-app || true
# sudo docker rm web-app || true
# sudo docker run -e DATABASE_URL ${{ secrets.DB_URL }} --restart-always -d --name web-app -p 3005:3000 imdeveshshukla/quiet-backend:latest
- name: Deploy
uses: appleboy/ssh-action@master #working
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker pull imdeveshshukla/quiet-backend:latest
sudo docker stop web-app || true
sudo docker rm web-app || true
sudo docker run --env-file .env --restart always -d --name web-app -p 3000:3000 imdeveshshukla/quiet-backend:latest
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ RUN npx prisma generate

EXPOSE 3000

CMD ["npm", "run", "dev"]
CMD ["npm", "run", "deploy"]
3 changes: 2 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "node src/server.js"
"dev": "nodemon src/server.js",
"deploy":"node src/server.js"
},
"author": "",
"license": "ISC",
Expand Down
24 changes: 12 additions & 12 deletions backend/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ dotenv.config({
})
const app = express()
const port = 3000
const whitelist = ['http://localhost:5173', 'http://localhost:3000']
const corsOptions = {
credentials:true,
origin: function (origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
}

app.use(cors(corsOptions));
credentials: true,
origin: 'https://www.bequiet.live',
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowedHeaders: [
"Origin",
"Content-Type",
"Accept",
"Authorization",
"X-Requested-With",
],
};
app.use('*',cors(corsOptions));
app.use(bodyParser.json())
app.use(express.json());
app.use(express.urlencoded({extended:true}));
Expand Down
2 changes: 2 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dist
dist-ssr
*.local

.env

# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/localhost.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const baseAddress = 'http://localhost:3000/'
export default baseAddress;
const baseAddress = "https://api.bequiet.live/"
export default baseAddress;

0 comments on commit 4a5d9c7

Please sign in to comment.