Skip to content

Commit

Permalink
chore: test
Browse files Browse the repository at this point in the history
  • Loading branch information
clean2001 committed Nov 1, 2024
1 parent 0c600db commit d4aca0b
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/test-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: deploy to aws s3
on:
push:
branches:
- chore/deploy
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: source code checkout
uses: actions/checkout@v2

- name: setup node.js
uses: actions/setup-node@v2
with:
node-version: "20"

- name: npm install
working-directory: .
run: npm install

- name: npm build
env:
VUE_APP_API_BASE_URL: ${{ secrets.BASE_URL }}
VUE_APP_MY_URL: ${{ secrets.MY_URL }}
VUE_APP_KAKAO_REDIRECT_URI: ${{ secrets.KAKAO_REDIRECT_URI }}
VUE_APP_KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }}
VUE_APP_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
VUE_APP_GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
VUE_APP_GOOGLE_REDIRECT_URI: ${{ secrets.GOOGLE_REDIRECT_URI }}
VUE_APP_PORTONE_STORE_ID: ${{ secrets.PORTONE_STORE_ID }}
VUE_APP_PORTONE_CHANNEL_KEY: ${{ secrets.PORTONE_CHANNEL_KEY }}
VUE_APP_FIREBASE_VAPID_KEY: ${{ secrets.FIREBASE_VAPID_KEY }}
VUE_APP_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
working-directory: .
run: npm run build

- name: setup docker buildx
uses: docker/setup-buildx-action@v2

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

- name: build vue-app image
run: docker build -t vue-app .

- name: setup aws cli
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET }}
aws-region: "ap-northeast-2"
- name: update cluster information
run: aws eks update-kubeconfig --name inong-cluster --region ap-northeast-2

- name: login ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1


- name: build and push docker product images to ecr
env:
REGISTRY: 676206947506.dkr.ecr.ap-northeast-2.amazonaws.com
REPOSITORY: inong/front
run: |
docker build -t $REGISTRY/$REPOSITORY:latest \
-f ./Dockerfile .
docker push $REGISTRY/$REPOSITORY:latest
- name: eks kubectl apply
run: |
kubectl apply -f ./k8s/vue-depl.yml
kubectl rollout restart deployment vue-app
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Stage 1: Build the Vue app
FROM node:16 AS build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# Stage 2: Serve with NGINX
FROM nginx:alpine AS production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
19 changes: 19 additions & 0 deletions k8s/vue-depl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vue-app
spec:
replicas: 2
selector:
matchLabels:
app: vue-app
template:
metadata:
labels:
app: vue-app
spec:
containers:
- name: vue-app
image: your-dockerhub-username/vue-app:latest # Replace with your Docker image
ports:
- containerPort: 80
12 changes: 12 additions & 0 deletions k8s/vue-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: vue-app-service
spec:
type: ClusterIP
selector:
app: vue-app
ports:
- protocol: TCP
port: 80
targetPort: 80
10 changes: 10 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server {
listen 80;
server_name localhost;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
Empty file added secret.yml
Empty file.

0 comments on commit d4aca0b

Please sign in to comment.