[TOC]
์๊ฐ์์ [ https://youtu.be/aoKpCYj-c7E ]
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.8.6",
"@types/jest": "^27.5.2",
"@types/node": "^17.0.45",
"@types/react": "^18.0.24",
"@types/react-dom": "^18.0.8",
"axios": "^1.1.3",
"cors": "^2.8.5",
"react": "^18.2.0",
"react-device-detect": "^2.2.2",
"react-dom": "^18.2.0",
"react-helmet-async": "^1.3.0",
"react-redux": "^8.0.4",
"react-router-dom": "^6.4.2",
"react-scripts": "5.0.1",
"typescript": "^4.8.4",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@types/react-router-dom": "^5.3.3"
}
}
server.servlet.context-path= /naya
server.port=8080
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.17.0.2:3306/naya?serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=eowjswkdbfb104
#spring
#spring.jpa.show-sql=true.jpa.database-platform=org.hibernate.dialect.MySql8Dialect
spring.jpa.hibernate.ddl-auto=update
#spring.mvc.pathmatch.matching-strategy=ant_path_matcher
# backend
FROM openjdk:8
WORKDIR /var/jenkins_home/workspace/NAYA/backend/naya
ENV TZ Asia/Seoul
COPY build/libs/NAYA-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]
# frontend
FROM node:16 as build-stage
# ์ฑ ๋๋ ํฐ๋ฆฌ ์์ฑ
WORKDIR /jenkins/workspace/NAYA/frontend
ENV TZ Asia/Seoul
# ์ฑ ์์กด์ฑ ์ค์น
# ๊ฐ๋ฅํ ๊ฒฝ์ฐ(npm@5+) package.json๊ณผ package-lock.json์ ๋ชจ๋ ๋ณต์ฌํ๊ธฐ ์ํด
# ์์ผ๋์นด๋๋ฅผ ์ฌ์ฉ
COPY package*.json ./
RUN npm install --save --legacy-peer-deps
# ํ๋ก๋์
์ ์ํ ์ฝ๋๋ฅผ ๋น๋ํ๋ ๊ฒฝ์ฐ
# RUN npm ci --only=production
# ์ฑ ์์ค ์ถ๊ฐ
COPY . .
RUN npm run build
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /jenkins/workspace/NAYA/frontend/build /usr/share/nginx/html
COPY --from=build-stage /jenkins/workspace/NAYA/frontend/deploy_conf/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]
- git clone
git clone https://lab.ssafy.com/s07-final/S07P31B104.git
-
๋์ปค ์ค์น ๋ฐ ๋์ปค ์ปดํฌ์ฆ ์ค์น
-
Dockerfile ๋ฐ docker-compose.yml์์ฑ
-
frontend Dockerfile
FROM node:16 as build-stage # ์ฑ ๋๋ ํฐ๋ฆฌ ์์ฑ WORKDIR /jenkins/workspace/NAYA/frontend ENV TZ Asia/Seoul # ์ฑ ์์กด์ฑ ์ค์น # ๊ฐ๋ฅํ ๊ฒฝ์ฐ(npm@5+) package.json๊ณผ package-lock.json์ ๋ชจ๋ ๋ณต์ฌํ๊ธฐ ์ํด # ์์ผ๋์นด๋๋ฅผ ์ฌ์ฉ COPY package*.json ./ RUN npm install --save --legacy-peer-deps # ํ๋ก๋์ ์ ์ํ ์ฝ๋๋ฅผ ๋น๋ํ๋ ๊ฒฝ์ฐ # RUN npm ci --only=production # ์ฑ ์์ค ์ถ๊ฐ COPY . . RUN npm run build FROM nginx:stable-alpine as production-stage COPY --from=build-stage /jenkins/workspace/NAYA/frontend/build /usr/share/nginx/html COPY --from=build-stage /jenkins/workspace/NAYA/frontend/deploy_conf/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 3000 CMD ["nginx", "-g", "daemon off;"]
-
backend dockerfile
FROM openjdk:8 WORKDIR /var/jenkins_home/workspace/NAYA/backend/naya ENV TZ Asia/Seoul #VOLUME /tmp #ARG JAR_FILE=build/libs/*.jar #COPY {JAR_FILE} app.jar #RUN ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime COPY build/libs/NAYA-0.0.1-SNAPSHOT.jar app.jar ENTRYPOINT ["java","-jar","app.jar"]
-
nginx.conf ํ์ผ
upstream backend{ ip_hash; server {๋ด๋ถ ๋ก์ปฌ ์ฃผ์:ํฌํธ๋ฒํธ}; ex)172.26.14.37:8080; } map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name {๋๋ฉ์ธ ์ฃผ์}; ex) k7b104.p.ssafy.io; location / { return 301 https://$host$request_uri; } #location /naya/api { # proxy_name http://localhost:8080/naya/api; #} } server { listen 443 ssl; # listen [::]:443; server_name {๋๋ฉ์ธ ์ฃผ์}; ex) k7b104.p.ssafy.io; access_log /var/log/nginx/host.access.log main; ssl_certificate /etc/letsencrypt/live/{๋๋ฉ์ธ ์ฃผ์}/fullchain.pem; # ex) ssl_certificate /etc/letsencrypt/live/k7b104.p.ssafy.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{๋๋ฉ์ธ ์ฃผ์}/privkey.pem; # ex) ssl_certificate_key /etc/letsencrypt/live/k7b104.p.ssafy.io/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3 SSLv3; ssl_ciphers ALL; location / { root /usr/share/nginx/html; index index.html index.htm; error_page 405 = $uri; proxy_redirect off; try_files $uri.html $uri $uri/ /index.html; charset utf-8; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; 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; proxy_set_header X-Nginx-Proxy true; } location /api/ { proxy_pass http://backend/; proxy_redirect off; charset utf-8; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; 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; proxy_set_header X-Nginx-Proxy true; }
-
docker-compose.yml
version: '3' services: jenkins: image: jenkins/jenkins:lts container_name: jenkins volumes: - /var/run/docker.sock:/var/run/docker.sock - /jenkins:/var/jenkins_home ports: - "9090:8080" privileged: true user: root
-
-
๋์ปค ์ปจํ ์ด๋ ์คํ
-
mysql ์ด๋ฏธ์ง ์คํํ๊ธฐ
# MySQL ์ปจํ ์ด๋ ์์ฑ docker run --name naya_DB -e MYSQL_ROOT_PASSWORD -d mysql # Dump ๋ฃ๊ธฐ docker cp {๋คํํ์ผ ์์น} naya_DB:/home # naya_DB ๋ด๋ถ ์ ์ docker exec -it naya_DB bash # Dump import mysql -hlocalhost -uroot -p{password} < /home/{๋คํํ์ผ๋ช }
- ๋๋ 3306ํฌํธ๋ก mySQL ์ ์ํ์ฌ naya ์คํค๋ง ์์ฑ
-
docker-compose ์คํ
sudo docker-compose up -d
-
์ ํจ์ค์ ์ ์ํด ๋น๋ ์ค์
- Build Steps - Excute shell ์ถ๊ฐ
docker image prune -a --force mkdir -p /var/jenkins_home/images cd /var/jenkins_home/workspace/NAYA/frontend/ docker build -t react . docker save react > /var/jenkins_home/images/react.tar cd /var/jenkins_home/workspace/NAYA/backend/NAYA/ chmod +x ./gradlew ./gradlew clean build docker build -t springboot . docker save springboot > /var/jenkins_home/images/springboot.tar ls /var/jenkins_home/images
- ๋น๋ ํ ์กฐ์น ์ถ๊ฐ
sudo docker load < /jenkins/images/react.tar sudo docker load < /jenkins/images/springboot.tar if (sudo docker ps -a | grep "react"); then sudo docker stop react; fi if (sudo docker ps -a | grep "springboot"); then sudo docker stop springboot; fi sudo docker run -it -d --rm -p 80:80 -p 443:443 -v /home/ubuntu/certbot/conf:/etc/letsencrypt/ -v /home/ubuntu/certbot/www:/var/www/certbot --name react react echo "Run frontend" sudo docker run -it -d --rm -p 8080:8080 --name springboot springboot echo "Run backend"
- ์๋ ํ์ธ
-
์คํ ์ค์ธ ์ปจํ ์ด๋ ์กฐํ
docker ps
- ๋๋ง์ ์ปค์คํ ๋ฉํฐ๋ฏธ๋์ด ์นด๋(Naya) ์ ์
- Naya ์นด๋๋ SNS ๋ฑ์์ ์ ๋จธ์๊ฒ ์์ ์ ํํํ๋ ์๋จ์ผ๋ก ํ์ฉ ๊ฐ๋ฅ
- ๋ค์ํ Naya ์๊ฐ ์นด๋ ์์ฑ ๊ฐ๋ฅ
- ๋ค์ํ Naya ์๊ฐ ์นด๋๋ฅผ ๋ค์ํ ์ํฉ์ ๋ง๊ฒ ํ์ฉ ๊ฐ๋ฅ
- ์ฐ๋ฝ์ฒ๋ฅผ ๋ชจ๋ฅด๋ ์ฌ๋๊ณผ๋ ์นด๋ ๊ณต์ ๊ฐ๋ฅ
- QR์ฝ๋๋ฅผ ์ด์ฉํ ์นด๋ ๊ณต์
- ์นด์นด์คํก์ ์ด์ฉํ ์นด๋ ๊ณต์
- ์ธ์คํ๊ทธ๋จ์ ์ด์ฉํ ์นด๋ ๊ณต์
- ๋น ๋ฅธ ๋ช ํจ ๋ฑ๋ก ๊ณผ์
- ๋ช
ํจ ์ดฌ์์ ํตํ ๋ฑ๋ก
- ๊ฐค๋ฌ๋ฆฌ๋ฅผ ํตํ ๊ธฐ์กด ์ด๋ฏธ์ง ๋ฑ๋ก
- ํ
ํ๋ฆฟ์ ์ด์ฉํ ๋ช
ํจ ์์ฑ ๋ฐ ๋ฑ๋ก
- ๋น์ฆ๋์ค ์ํฉ / ์บ์ฃผ์ผ ์ํฉ ๋ชจ๋ ํ์ฉ ๊ฐ๋ฅ
- Naya, Nuya ์๊ฐ ์นด๋
- Naya ์๊ฐ ์นด๋ : ๋์ ์๊ฐ ์นด๋
- Nuya ์๊ฐ ์นด๋ : ์๋๋ฐฉ์ด ๊ณต์ ํ ์๊ฐ ์นด๋
- Business Naya, Nuya ๋ช
ํจ ์นด๋
- Business Naya ์นด๋ : ์ฌ์ฉ์ ๋ณธ์ธ ๋ช
ํจ
- Business Nuya ์นด๋ : ์๋๋ฐฉ์ด ๊ณต์ ํ ๋ช
ํจ
- ๐ ํ๋ก ํธ์๋: React 18.2.0
- ๐ ๋ฐฑ์๋: Java 1.8, SpringBoot 2.5.5
- ๐ก DB : Firebase, Room (SQLite)
- ๐ณ ์ด์์ฒด์ , ์๋ฒ: Ubuntu 20.04
- ๐ฒ ๋ชจ๋ฐ์ผ : Android, Kotlin, Jetpack Compose, Jetpack Navigation, CameraX, Retrofit2
- ๐๏ธ OCR: OpenCV, Tesseract
- Git
- Jira
- Notion
- Mattermost
- Webex