Skip to content

Commit

Permalink
Merge pull request #106 from woowacourse-teams/feat/#103
Browse files Browse the repository at this point in the history
프론트엔드 CI / CD 스크립트 추가
  • Loading branch information
pricelees authored Jul 24, 2024
2 parents 67ebf4a + 82e1d38 commit c4dd53d
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/cd-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: frontend-deploy

on:
push:
branches:
- develop-frontend

jobs:
deploy:
runs-on: self-hosted

steps:
- name: Log in to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: allow ubuntu to access actions-runner
run: |
sudo chown -R ubuntu:ubuntu ~/actions-runner
- name: grant permission to docker-compose
run: |
sudo chmod +x ./frontend/docker-compose-fe.yml
- name: docker compose down
run: |
docker compose -f ./frontend/docker-compose-fe.yml down
- name: docker compose pull
run: |
docker compose -f ~/frontend/docker-compose-fe.yml pull
- name: docker compose up
run: |
docker compose -f ~/frontend/docker-compose-fe.yml up -d
50 changes: 50 additions & 0 deletions .github/workflows/ci-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: frontend-integration

on:
pull_request:
branches:
- develop-frontend

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: ./frontend

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: develop-frontend

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.15.0'

- name: Create .env file
run: |
echo "BASE_URL=${{ secrets.BASE_URL }}" > .env
- name: Install Dependencies
run: npm install --frozen-lockfile

- name: Build static file
run: npm run build

- name: Build Docker image
run: |
docker buildx build ./ --platform=linux/arm64 -t ${{ secrets.DOCKER_USERNAME }}/mouda-fe:latest
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Push Docker image to DockerHub
run: docker push ${{ secrets.DOCKER_USERNAME }}/mouda-fe:latest

8 changes: 8 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM nginx:latest

COPY dist /usr/share/nginx/html
COPY conf.d /etc/nginx/conf.d

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
52 changes: 52 additions & 0 deletions frontend/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
server {
listen 80;

location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}

location /v1/ {
proxy_pass http://localhost:8080;
proxy_set_header HOST $http_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;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
charset utf-8;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

0 comments on commit c4dd53d

Please sign in to comment.