-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b65acc
commit 8f09fd4
Showing
7 changed files
with
179 additions
and
10 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,3 @@ | ||
node_modules | ||
dist | ||
.github |
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,64 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
ECR_REGISTRY: 078512149071.dkr.ecr.ap-northeast-2.amazonaws.com | ||
ECR_REPOSITORY: uhdre-gamdi-web | ||
EKS_CLUSTER_NAME: goormthon-cluster | ||
AWS_REGION: ap-northeast-2 | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
VITE_API_URL: ${{ secrets.VITE_API_URL }} | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
|
||
- name: get-npm-version | ||
id: package-version | ||
uses: martinbeentjes/npm-get-version-action@main | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build Docker image | ||
id: build-image | ||
run: | | ||
docker build \ | ||
--build-arg VITE_API_URL=${{ env.VITE_API_URL }} \ | ||
-t ${{ env.ECR_REPOSITORY }}:${{ steps.package-version.outputs.current-version}} \ | ||
. | ||
- name: Tag Docker iamge | ||
id: tag-image | ||
run: docker tag ${{ env.ECR_REPOSITORY }}:${{ steps.package-version.outputs.current-version}} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ steps.package-version.outputs.current-version}} | ||
|
||
- name: Push Docker image to Amazon ECR | ||
id: push-image | ||
run: docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ steps.package-version.outputs.current-version}} | ||
|
||
- name: Configure EKS | ||
id: configure-eks | ||
run: aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ env.EKS_CLUSTER_NAME }} | ||
|
||
- name: Apply yaml | ||
id: apply-yaml | ||
env: | ||
ECR_REGISTRY: 078512149071.dkr.ecr.ap-northeast-2.amazonaws.com | ||
ECR_REPOSITORY: uhdre-gamdi-web | ||
TAG: ${{ steps.package-version.outputs.current-version}} | ||
run: envsubst < index.yaml | kubectl apply -f - |
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,26 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
branches: ['main'] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.x' | ||
|
||
- name: Install Deps | ||
run: npm install | ||
|
||
- name: Lint | ||
run: npm run build |
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
FROM nginx | ||
FROM node:alpine as build | ||
|
||
RUN mkdir /app | ||
ARG VITE_API_URL=${VITE_API_URL} | ||
ENV VITE_API_URL=${VITE_API_URL} | ||
|
||
WORKDIR /app | ||
|
||
RUN mkdir ./build | ||
COPY ./package.json ./ | ||
|
||
ADD ./dist ./build | ||
RUN npm install | ||
|
||
RUN rm /etc/nginx/conf.d/default.conf | ||
COPY . . | ||
|
||
COPY ./nginx.conf /etc/nginx/conf.d | ||
RUN export VITE_API_URL=${VITE_API_URL} && npm run build | ||
|
||
EXPOSE 80 | ||
FROM nginx:alpine | ||
|
||
RUN rm -rf /usr/share/nginx/html/* | ||
|
||
COPY --from=build /app/dist /usr/share/nginx/html | ||
|
||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["nginx", "-g", "daemon off;"] |
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,64 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: uhdre-gamdi-web | ||
--- | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: alb | ||
namespace: uhdre-gamdi-web # 각자 서비스의 ns로 변경 | ||
annotations: | ||
alb.ingress.kubernetes.io/scheme: internet-facing | ||
alb.ingress.kubernetes.io/target-type: ip | ||
spec: | ||
ingressClassName: alb | ||
rules: | ||
- http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: web-svc-alb | ||
port: | ||
number: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web-svc-alb | ||
namespace: uhdre-gamdi-web # 각자 서비스의 ns로 변경 | ||
labels: | ||
app: web | ||
spec: | ||
type: NodePort | ||
selector: | ||
app: web | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web-deploy-alb | ||
namespace: uhdre-gamdi-web # 각자 서비스의 ns로 변경 | ||
labels: | ||
app: web | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: ${ECR_REGISTRY}/${ECR_REPOSITORY}:${TAG} | ||
ports: | ||
- containerPort: 80 |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
server { | ||
listen 80; | ||
server_name _; | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
location / { | ||
root /app/build; | ||
index index.html; | ||
try_files $uri $uri/ /index.html; | ||
} | ||
} |
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