Skip to content

Commit 0bf2e47

Browse files
authored
Merge pull request #12 from DealerDotCom/feature/local_build
Setting up a dockerized local env
2 parents 5c42a3e + e8bd73a commit 0bf2e47

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ build/
2222
_yardoc
2323
doc/
2424
.idea/
25+
source/index.html.md

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Added
10+
11+
- Added ability to run project locally via a dockerized container.
912

1013
## [v2021-05-21T19.31.40] - 2021-05-21
1114

local/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM ruby:2.7-alpine
2+
3+
COPY build-local-doc.sh /usr/bin/
4+
5+
RUN apk --no-cache --update add nodejs g++ make coreutils git && \
6+
git clone https://github.com/slatedocs/slate.git /slate && cd slate \
7+
&& echo 'gem "middleman-livereload", "~> 3.4.3"' >> Gemfile \
8+
&& echo 'activate :livereload' >> config.rb \
9+
&& bundle install \
10+
&& chmod +x /usr/bin/*.sh
11+
12+
WORKDIR /slate
13+
14+
EXPOSE 4567
15+
16+
ENTRYPOINT ["sh", "/usr/bin/build-local-doc.sh"]

local/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Local Setup
2+
3+
We use a dockerized ruby environment to build and watch your local changes.
4+
5+
## Building your docker
6+
7+
Run the following command in this directory to set up the docker container
8+
9+
```docker build -t wiapi-doc .```
10+
11+
## Run your docker container
12+
13+
Run the following command in this directory to build and watch the external document
14+
15+
```docker run --rm -v ${PWD%/*}/source:/slate/source -p 4567:4567 -it wiapi-doc external```
16+
17+
Run the following command in this directory to build and watch the internal document
18+
19+
```docker run --rm -v ${PWD%/*}/source:/slate/source -p 4567:4567 -it wiapi-doc internal```
20+
21+
## View the document in your local
22+
23+
The document would be available in [http://localhost:4567](http://localhost:4567).
24+
25+
Once, you have your docker container running.

local/build-local-doc.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
function cleanup {
4+
echo "Removing the generated index.html.md file"
5+
rm source/index.html.md
6+
}
7+
8+
trap cleanup EXIT
9+
10+
echo "Deleting old 'build' folder if exists ..."
11+
rm -rf source/build
12+
13+
echo "Generating a index.html.md file for the $1 doc..."
14+
if [ $1 = "external" ]; then
15+
cp source/index.html.external.md source/index.html.md
16+
elif [ $1 = "internal" ]; then
17+
cp source/index.html.internal.md source/index.html.md
18+
else
19+
echo "Unknown argument '$1', will do nothing and exit"
20+
echo "Accepted arguments: external, internal"
21+
fi
22+
23+
echo "Building static html doc to 'build' folder ..."
24+
bundle exec middleman build --clean
25+
26+
echo "Copying result into 'build' folder ..."
27+
cp -r build source/
28+
29+
echo "Serving live doc at http://127.0.0.1:4567 ..."
30+
bundle exec middleman server

0 commit comments

Comments
 (0)