https://github.com/slatedocs/slate/wiki/Using-Slate-Natively
Using Slate Natively
James Evans edited this page <relative-time datetime="2020-06-12T14:06:28Z" class="no-wrap" title="2020年6月12日 GMT+8 下午10:06" style="box-sizing: border-box; white-space: nowrap !important;">on 12 Jun</relative-time> · 3 revisions
This page is for installing and using Slate on the native OS, as opposed to using Vagrant or Docker.
Dependencies
Minimally, you will need the following:
Please note, only Linux and macOS are officially supported at this time. While slate should work on Windows, it is unsupported.
See below for installation instructions for different OSes / distros.
Installing Dependencies on Ubuntu 18.04+
Install Ruby, NodeJS, and tools for compiling native ruby gems:
sudo apt install ruby ruby-dev build-essential libffi-dev zlib1g-dev liblzma-dev nodejs patch
Update RubyGems and install bundler:
sudo gem update --system
sudo gem install bundler
Installing Dependencies on macOS
First, install homebrew, then install xcode command line tools:
xcode-select --install
Agree to the Xcode license:
sudo xcodebuild -license
Install nodejs runtime:
brew install node
Update RubyGems and install bundler:
gem update --system
gem install bundler
Getting Set Up
- Fork this repository on Github.
- Clone your forked repository (not our original one) to your hard drive with
git clone https://github.com/YOURUSERNAME/slate.git
cd slate
- Install ruby gems for slate:
# either run this to run locally
bundle install
Note: if the above fails on installing nokogiri and using macOS see here for some helpful tips on things that might help.
Running slate
You can run slate in two ways, either as a server process for development, or just build html files.
To do the first option, run:
bundle exec middleman server
and you should see your docs at http://localhost:4567. Whoa! That was fast!
The second option (building html files), run:
bundle exec middleman build
What Now?
The next step is to learn how to edit source/index.md
to change the content of your docs. Once you're done, you might want to think about deploying your docs.
Dockerfile
FROM ubuntu:18.04
RUN apt -y update && \
apt -y install nginx && /etc/init.d/nginx stop && \
apt -y install ruby ruby-dev build-essential libffi-dev zlib1g-dev liblzma-dev nodejs patch && \
gem update --system && \
gem install bundler && \
mkdir -p /data/app
COPY nginx/docs-en.conf /etc/nginx/conf.d/docs-en.conf
COPY nginx/docs-zh.conf /etc/nginx/conf.d/docs-zh.conf
COPY nginx/start.sh /bin/start.sh
ADD . /data/
WORKDIR /data/docs_en/apiDoc
RUN bundle install && \
bundle exec middleman build
WORKDIR /data/docs_zh/apiDoc
RUN bundle install && \
bundle exec middleman build
ENTRYPOINT ["sh", "/bin/start.sh"]
start.sh
#!/bin/bash
/usr/sbin/nginx -g 'daemon off;'
网友评论