-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#docker-compose for server | ||
|
||
#version: '3.5' | ||
#services: | ||
# frontend: | ||
# container_name: frontend | ||
# image: ghcr.io/24fsiit16/dear-dev-frontend:latest | ||
# restart: always | ||
# # environment: | ||
# # - AUTH_TRUST_HOST=true | ||
# # - NEXTAUTH_URL=00000001 | ||
# ports: | ||
# - "3000:3000" | ||
|
||
#backend: | ||
# container_name: backend | ||
# image: ghcr.io/24fsiit16/dear-dev-backend:latest | ||
# ports: | ||
# - "8080:8080" | ||
|
||
# nginx: | ||
# container_name: nginx | ||
# image: nginx:latest | ||
# ports: | ||
# - "80:80" | ||
# volumes: | ||
# - ./nginx.conf:/etc/nginx/nginx.conf | ||
# depends_on: | ||
# - frontend | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#NGINX | ||
|
||
#GNU nano 6.2 nginx.conf * | ||
# events {} | ||
# | ||
# http { | ||
# server { | ||
# listen 80; | ||
# server_name _; | ||
# | ||
# location / { | ||
# proxy_pass http://frontend:3000; | ||
# proxy_set_header Host $host; | ||
# proxy_set_header X-Real-IP $remote_addr; | ||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
# proxy_set_header X-Forwarded-Proto $scheme; | ||
# } | ||
# | ||
# location /api/ { | ||
# proxy_pass http://backend:8080; | ||
# proxy_set_header Host $host; | ||
# proxy_set_header X-Real-IP $remote_addr; | ||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
# proxy_set_header X-Forwarded-Proto $scheme; | ||
# } | ||
# } | ||
#} | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,10 @@ jobs: | |
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
node-version: '22.4.1' | ||
|
||
- name: Clear npm cache | ||
run: npm cache clean --force | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
@@ -30,7 +33,7 @@ jobs: | |
- name: Run ESLint | ||
run: npm run lint | ||
|
||
build_and_push: | ||
build_and_publish: | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/main' | ||
needs: test | ||
|
@@ -42,7 +45,7 @@ jobs: | |
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
node-version: '22.4.1' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
@@ -60,7 +63,39 @@ jobs: | |
run: | | ||
REPO_NAME=ghcr.io/${{ github.repository_owner }}/dear-dev-frontend | ||
LOWER_REPO_NAME=$(echo $REPO_NAME | tr '[A-Z]' '[a-z]') | ||
DATE_TAG=$(date +%Y%m%d) | ||
docker build --build-arg SECRET_KEY_NEXT_AUTH=${{ secrets.SECRET_KEY_NEXT_AUTH }} -t $LOWER_REPO_NAME:latest -t $LOWER_REPO_NAME:$DATE_TAG . | ||
docker build --build-arg SECRET_KEY_NEXT_AUTH=${{ secrets.SECRET_KEY_NEXT_AUTH }} -t $LOWER_REPO_NAME:latest . | ||
docker push $LOWER_REPO_NAME:latest | ||
docker push $LOWER_REPO_NAME:$DATE_TAG | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build_and_publish | ||
name: deploy image | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
- name: Deploy to server | ||
env: | ||
JWT_SECRET: ${{ secrets.JWT_SECRET }} | ||
SSH_USER: ${{ secrets.SSH_USER }} | ||
SSH_HOST: ${{ secrets.SSH_HOST }} | ||
SSH_ITALIAN_PASSWORD: ${{ secrets.SSH_ITALIAN_PASSWORD }} | ||
SSH_ITALIAN_USER: ${{ secrets.SSH_ITALIAN_USER }} | ||
run: | | ||
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} <<'EOF' | ||
echo '${{ secrets.SSH_ITALIAN_PASSWORD }}' | sudo -S su - ${{ secrets.SSH_ITALIAN_USER }} -c ' | ||
cd ~/yappi && | ||
docker-compose stop frontend nginx && | ||
docker-compose rm frontend nginx && | ||
docker pull ghcr.io/24FSIIT16/dear-dev-frontend:latest | ||
docker-compose up -d frontend nginx ' | ||
EOF | ||
- name: cleanup | ||
run: rm -rf ~/.ssh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters