diff --git a/.github/workflows/deploy-front.yml b/.github/workflows/deploy-front.yml index 5c0788d..80b6a15 100644 --- a/.github/workflows/deploy-front.yml +++ b/.github/workflows/deploy-front.yml @@ -25,7 +25,7 @@ jobs: - name: Build and Push Docker Image uses: docker/build-push-action@v3 with: - context: . + context: ./client file: ./client/Dockerfile push: true tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/front diff --git a/client/Dockerfile b/client/Dockerfile index b887621..3808dac 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,21 +1,21 @@ # 첫 번째 단계: 빌드 환경 구축 -FROM node:lts-alpine as build-stage +FROM --platform=linux/amd64 node:lts-alpine as build-stage WORKDIR /app # 의존성 파일 복사 및 설치 -COPY ./client/package.json ./client/yarn.lock ./ +COPY package.json yarn.lock ./ RUN yarn install && yarn global add typescript # 소스 코드 복사 -COPY ./client . +COPY . . RUN ls -l # 애플리케이션 빌드 RUN yarn build # 두 번째 단계: Nginx를 사용하여 애플리케이션 서빙 -FROM nginx:stable-alpine as production-stage +FROM --platform=linux/amd64 nginx:stable-alpine as production-stage # 빌드된 파일을 Nginx 서버로 복사 COPY --from=build-stage /app/dist /usr/share/nginx/html @@ -24,4 +24,4 @@ COPY --from=build-stage /app/dist /usr/share/nginx/html EXPOSE 80 # Nginx 실행 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5e5baf4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,87 @@ +version: '3' + +services: + db: + image: mysql + env_file: .env + networks: + - custom_network + ports: + - 3306:3306 + environment: + MYSQL_ROOT_PASSWORD: ${DB_PW} + volumes: + - ./server/api-server/sql:/docker-entrypoint-initdb.d + + redis: + image: redis + env_file: .env + networks: + - custom_network + ports: + - 6379:6379 + + api-server: + depends_on: + - db + - redis + build: ./server/api-server + env_file: ./server/api-server/.env + networks: + - custom_network + ports: + - 3000:3000 + environment: + DB_HOST: db + DB_PORT: ${DB_PORT} + DB_ID: root + DB_PW: ${DB_PW} + DB_NAME: ${DB_NAME} + VIDEO_STAT_URL: http://host.docker.internal:802/stat + REDIS_URL: redis://redis:6379 + NAVER_CLIENT_ID: ${NAVER_CLIENT_ID} + NAVER_CLIENT_SECRET: ${NAVER_CLIENT_SECRET} + NAVER_CALLBACK_URL: ${NAVER_CALLBACK_URL} + SESSION_SECRET: ${SESSION_SECRET} + CLIENT_ORIGIN: ${CLIENT_ORIGIN} + ENCODING_URL: rtmp://172.20.0.10/stream + + rtmp-server: + build: ./server/rtmp-server + networks: + - custom_network + ports: + - 1935:1935 + - 802:80 + environment: + STREAM_KEY_CHECK_URL: http://host.docker.internal:3000/stream-keys + + encoding-server: + image: efriandika/streaming-server + privileged: true + env_file: .env + networks: + custom_network: + ipv4_address: 172.20.0.10 + ports: + - 19350:1935 + - 803:80 + environment: + AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID} + AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY} + AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME} + AWS_S3_REGION: ${AWS_S3_REGION} + AWS_S3_URL: ${AWS_S3_URL} + + front: + build: ./client + networks: + - custom_network + ports: + - 80:80 + +networks: + custom_network: + ipam: + config: + - subnet: 172.20.0.0/16 diff --git a/server/rtmp-server/Dockerfile b/server/rtmp-server/Dockerfile index 5e77d70..962d37c 100644 --- a/server/rtmp-server/Dockerfile +++ b/server/rtmp-server/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.13.4 as builder +FROM --platform=linux/amd64 alpine:3.13.4 as builder RUN apk add --update build-base git bash gcc make g++ zlib-dev linux-headers pcre-dev openssl-dev RUN git clone https://github.com/winshining/nginx-http-flv-module.git && \ @@ -7,7 +7,7 @@ RUN cd nginx && ./auto/configure --add-module=../nginx-http-flv-module && make & COPY ./nginx.conf /usr/local/nginx/conf/nginx.conf -FROM alpine:3.13.4 as nginx +FROM --platform=linux/amd64 alpine:3.13.4 as nginx RUN apk add --update pcre ffmpeg COPY --from=builder /usr/local/nginx /usr/local/nginx