Skip to content

Commit

Permalink
Refactor: 배포 자동화 작업 수정 (#37)
Browse files Browse the repository at this point in the history
* Refactor: Server Dockerfile 수정

패키지 매니저를 yarn으로 변경하면서 기존 Dockerfile이 동작하지 않게 되어 업데이트함.

* Refactor: build_push.sh 수정

npm 명령어를 사용하던 스크립트를 yarn을 사용하는 방식으로 변경

* Chore: 배포 스크립트 수정

yarn으로 변경한것에 맞춰서 스크립트 수정함.

* Fix: test 실행 스크립트 오류 수정

* Refactor: 프론트 Dockerfile 수정

nginx를 좀더 가벼운 이미지로 변경했습니다.
  • Loading branch information
changheedev authored Oct 29, 2020
1 parent 38f4d3d commit 6dd9f41
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 37 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Install yarn
run: |
npm install -g yarn
yarn install
- name: Run tests
env:
DB_USERNAME: user
DB_PASSWORD: password
DB_DATABASE: test
run: |
chmod +x ./scripts/run-test.sh
./scripts/run-test.sh
run: yarn test
- name: Build & Push Docker Images
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
Expand Down
2 changes: 1 addition & 1 deletion front/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx
FROM nginx:alpine

COPY myapp.conf /etc/nginx/conf.d/default.conf
COPY dist /usr/share/nginx/html
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"server"
],
"scripts": {
"test": "run-s test:server test:front",
"test": "yarn test:server",
"test:server": "yarn workspace server test",
"test:front": "yarn workspace front test",
"precommit:server": "yarn workspace server precommit",
Expand Down
14 changes: 4 additions & 10 deletions scripts/build_push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ DOCKER_PASSWORD=$3

docker login --username $DOCKER_USER --password $DOCKER_PASSWORD || exit 1

cd server

npm install
npm run build
docker build -t $beRepoName .
yarn workspace server build
docker build -t $beRepoName ./server

for tag in ${tags[@]}; do
docker tag $beRepoName ${beRepoName}:${tag}
docker push ${beRepoName}:${tag}
done

cd ../front

npm install
npm run build
docker build -t $feRepoName .
yarn workspace front build
docker build -t $feRepoName ./front

for tag in ${tags[@]}; do
docker tag $feRepoName ${feRepoName}:${tag}
Expand Down
11 changes: 0 additions & 11 deletions scripts/run-test.sh

This file was deleted.

13 changes: 3 additions & 10 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
FROM node:12.18.3-alpine

# 앱 디렉터리 생성
WORKDIR /usr/src/app

# 앱 의존성 설치
# 가능한 경우(npm@5+) package.json과 package-lock.json을 모두 복사하기 위해
# 와일드카드를 사용
COPY package*.json ./
COPY dist/* .
COPY package.json .

RUN npm ci --only=production

COPY ./dist ./
COPY ./.env.template ./
RUN yarn install --production

EXPOSE 8080

CMD [ "node", "server.js" ]

0 comments on commit 6dd9f41

Please sign in to comment.