-
Notifications
You must be signed in to change notification settings - Fork 2
Ec2 deploy 깃헙액션 docker관련 명령어 sudo추가 #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23dbe48
698ed91
b6cb35d
55f4a75
2763cf3
cf2157a
4ec8eaf
2b3894e
d1ca615
0a0ea18
eda3e43
86acdfe
978b3aa
a16fd87
ee6afc7
70ebaa3
bcc1cd5
7d5250b
02b17e6
7041351
5bf678b
5104f2a
df656bb
a5446c8
fabde4e
68ce4ea
21316d4
272432d
2e05c03
583c613
d29eeff
7a7a68a
3136c68
8801660
5c7a59d
3dc406c
b2629d4
dfac342
f065d94
525b888
8bf61b6
f08aa2a
08b4560
ee7a20e
1eb042b
396aab4
9387475
ab5fa12
8ee477b
d294635
55a220a
f07a016
e1b6af9
891c5e5
c2f7bec
08de64e
3f3ad2d
3d64154
99ac5b6
1589563
6a2f808
25a404b
23bc5da
af4bcf6
7c97603
d494c02
d313a9c
059e897
15c7ec4
2e7f446
b2f3216
5f81d91
c4a0e97
b7c9b3a
074ebf4
bc22043
010a449
a5e0ba9
be8d56d
4b3ae63
3ac8db2
3544b0a
3df8115
f290846
6d9f881
e8f1572
5e429ea
96c1443
81f8a50
2880789
2b186c7
0fa30b6
48d36d9
7a294f4
f996952
fc1fc8c
0843420
e551646
8084437
4c51f90
7335ef3
398f6c5
d4527a1
80b7d35
43e0d7b
e5eebd3
742c292
fc3f8b0
6b0e02b
b05e3a5
efee88a
71b6498
b78646d
8543b55
e750173
7cd8527
78d9b87
4d28b75
075108f
92fce12
96cb9c9
5aa099c
c07c9be
c6b066d
e3d324e
53f6b09
48e5a1f
f4aee9e
4766a1f
4a699eb
560ac3a
c47a3ae
64d852c
a79faf5
d94ae03
ef1704c
e139d51
f1bbeb7
d979b2f
0b677bb
d3128af
10af986
964efaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,8 +25,8 @@ jobs: | |||||||||||||||||
| # 2. Docker 이미지 빌드, 태그, 푸시 (이미지 이름 형식 변경) | ||||||||||||||||||
| - name: Build and push to Docker Hub | ||||||||||||||||||
| run: | | ||||||||||||||||||
| docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} . | ||||||||||||||||||
| docker push ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
| sudo docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} . | ||||||||||||||||||
| sudo docker push ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
|
|
||||||||||||||||||
| # 3. EC2에 접속하여 배포 | ||||||||||||||||||
| - name: Deploy to EC2 instance | ||||||||||||||||||
|
|
@@ -37,14 +37,13 @@ jobs: | |||||||||||||||||
| key: ${{ secrets.EC2_SSH_KEY }} | ||||||||||||||||||
| script: | | ||||||||||||||||||
| # EC2에서 Docker Hub 이미지 pull | ||||||||||||||||||
| docker pull ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
| sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
|
|
||||||||||||||||||
| # 기존 컨테이너 중지 및 삭제 | ||||||||||||||||||
| if [ $(docker ps -q -f name=motimo-fe-production) ]; then | ||||||||||||||||||
| docker stop motimo-fe-production | ||||||||||||||||||
| docker rm motimo-fe-production | ||||||||||||||||||
| if [ $(sudo docker ps -q -f name=motimo-fe-production) ]; then | ||||||||||||||||||
| sudo docker stop motimo-fe-production | ||||||||||||||||||
| sudo docker rm motimo-fe-production | ||||||||||||||||||
| fi | ||||||||||||||||||
|
Comment on lines
+43
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix container existence check; current test breaks on empty output and misses stopped containers.
Apply: - if [ $(sudo docker ps -q -f name=motimo-fe-production) ]; then
- sudo docker stop motimo-fe-production
- sudo docker rm motimo-fe-production
- fi
+ cid="$(sudo docker ps -aq -f name=^motimo-fe-production$)"
+ if [ -n "$cid" ]; then
+ sudo docker rm -f "$cid"
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| # 새 컨테이너 실행 | ||||||||||||||||||
| docker run -d --name motimo-fe-production -p 3000:3000 --restart always --env-file ./production.env ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
|
|
||||||||||||||||||
| sudo docker run -d --name motimo-fe-production -p 3000:3000 --restart always --env-file ./production.env ${{ secrets.DOCKERHUB_USERNAME }}/motimo-fe-production:${{ github.sha }} | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Log in to Docker Hub on EC2 before pulling if the repo is private; add fail-fast.
Without a remote docker login, sudo docker pull will fail for private images.
Apply:
🏁 Script executed:
Length of output: 943
Add Docker login and fail-fast in production-deploy workflow
Without authenticating first,
sudo docker pullwill fail on private images. Prepend the deploy script with strict error handling and, when credentials are set, log in before pulling:📝 Committable suggestion
🤖 Prompt for AI Agents