Skip to content

Commit

Permalink
Merge pull request #54 from GDSC-PKNU-21-22/feat/#53
Browse files Browse the repository at this point in the history
Feat/#53: 깃허브 액션으로 배포 자동화 구현하기
  • Loading branch information
pp449 authored Jul 31, 2023
2 parents b35298c + 074500f commit 6572715
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 68 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Workflow
on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: docker image build
run: docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }} .

- name: docker hub login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PW }}

- name: docker hub publish
run: docker push ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}

- name: connect EC2 Instance
uses: appleboy/[email protected]
with:
host: ${{ secrets.REMOTE_IP }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_PRIVATE_KEY }}
script: |
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker pull ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}
docker run -d -p 8080:8080 --env-file ./sec/.env --name burimi-back ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_IMAGE_NAME }}
28 changes: 0 additions & 28 deletions .github/workflows/release.yml

This file was deleted.

14 changes: 5 additions & 9 deletions src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ if (process.env.NODE_ENV === 'development') {
} else {
DBHost = env.DB_HOST;
}
const db = mysql.createConnection({
const db = mysql.createPool({
host: DBHost,
user: env.DB_USER,
password: env.DB_PW,
database: env.DB_NAME,
});

db.connect((error) => {
if (error) {
console.error('MySQL 연결 실패:', error);
} else {
console.log('MySQL 연결 성공!');
}
waitForConnections: true,
queueLimit: 0,
enableKeepAlive: true,
keepAliveInitialDelay: 10000,
});

export default db;
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ app.get('/test', (req: Request, res: Response) => {
});

app.listen(env.SERVER_PORT, () => {
console.log('서버 실행중');
console.log(env.SERVER_PORT, '포트 서버 실행중');
});
30 changes: 0 additions & 30 deletions src/tests/dbConnect.test.ts

This file was deleted.

0 comments on commit 6572715

Please sign in to comment.