Skip to content

Commit

Permalink
[feat] docker-compose 로컬 테스트 환경 구축 (#118)
Browse files Browse the repository at this point in the history
* refactor: 프론트 배포 코드 수정

* refactor: Dockerfile --platform=linux/amd64 추가

* feat: docker-compose 로컬 테스트 환경 구축
  • Loading branch information
kkg5 authored Dec 4, 2023
1 parent cc27a8a commit b5f4bc9
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-front.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,4 +24,4 @@ COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80

# Nginx 실행
CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
87 changes: 87 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions server/rtmp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand All @@ -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
Expand Down

0 comments on commit b5f4bc9

Please sign in to comment.