본문 바로가기
카테고리 없음

Slate로 API 문서 작성하고 배포하기 (window10/docker)

by danny_l 2021. 3. 22.

API document 를 html 페이지로 만들어주는 도구

 

아래의 3가지 방법중 하나를 선택해 실행하면 된다. 나는 Docker를 사용해서 실행하는 것을 선택했다.

github.com/slatedocs/slate/wiki/Using-Slate-in-Docker

 

slatedocs/slate

Beautiful static documentation for your API. Contribute to slatedocs/slate development by creating an account on GitHub.

github.com

 

Docker 환경 세팅

 

1. 윈도우 터미널 설치

2. 관리자 권한으로 실행

3. DISM 실행 (DISM: 윈도우 이미지Windows images와 관련된 조작을 위한 커맨드라인 명령어)

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart > dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

 

4. wsl 설치

> wsl

입력 결과로 나오는 페이지로 이동하여 우분투 배포판 설치

5. 사용자 정보등록

6. 설치 확인 

> wsl -l -v
  • 재부팅 
  • 업데이트 하라고 하면 업데이트 하기

7. wsl2로 업데이트

> wsl --set-version Ubuntu 2
> wsl --set-default-version 2
> wsl -t Ubuntu
> wsl -l -v
  Name           State         Version
* Ubuntu         Running       2

8. terminal 에서 우분투 셸 실행

9. 도커 데스크탑 설치

https://hub.docker.com/editions/community/docker-ce-desktop-windows

 

Docker Desktop for Windows

We and third parties use cookies or similar technologies ("Cookies") as described below to collect and process personal data, such as your IP address or browser information. You can learn more about how this site uses Cookies by reading our privacy policy

hub.docker.com

  • General 탭에서 Use the WSL2 based engine 옵션 체크
  • Resource -> WSL Integration 페이지로 이동해서 설정 확인
> docker ps  //도커 실행여부확인
> ip addr show eth0 //WSL2 우분투 IP 주소 확인

10. 도커로 Nginx 서버를 실행

$ docker run -it -p 80:80 nginx:latest

확인한 ip로 접속시 브라우저로 확인 가능

 

여기까지 하면 드디어 slate를 가져올 준비가 되었다....

그리고 ruby bundler nodejs도 설치해야 했던거같은데...이부분은 나중에 추가할 예정 (과연..)


slate 가져오기!

  1. Clone your forked repository (not our original one) to your hard drive with git clone <https://github.com/YOURUSERNAME/slate.git>
  2. cd slate
  3. Grab the slate image (docker pull slatedocs/slate) or build the docker image for the repository (docker build . -t slatedocs/slate).
git clone https://github.com/계정명/slate.git
cd slate
docker pull slatedocs/slate
docker run --rm --name slate -v $(pwd)/build:/srv/slate/build -v $(pwd)/source:/srv/slate/source slatedocs/slate

http://localhost:4567 로 접속하여 설치 확인 하고

source/index.html.md 를 수정하여 문서를 작성하면 됨 😎


github page로 배포하기 🥳

> cd slate

slate 폴더로 이동한 상태에서 진행

gem 파일 설치

gem install therubyracer
bundle install
./deploy.sh

CssSyntaxError 오류....

bundler: failed to load command: middleman (/.rbenv/versions/2.7.2/bin/middleman)
ExecJS::RuntimeError: CssSyntaxError: /stylesheets/screen.css:5:1: Unknown word

config.rb 파일에서 activate :sprockets 부분 지우고 다시 deploy

github.com/middleman/middleman/issues/2302

이거 보고 겨우 해결함..

 

배포하고 다시 빌드할때...

> docker run --rm --name slate -v $(pwd)/build:/srv/slate/build -v $(pwd)/source:/srv/slate/source slatedocs/slate
> ./deploy.sh

 

참고