Skip to content

Commit

Permalink
added Dockerfile and hexo.sh script to run local server in the docker…
Browse files Browse the repository at this point in the history
… container
  • Loading branch information
wololock committed Nov 28, 2019
1 parent aa96427 commit 3147104
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
@@ -0,0 +1,8 @@
FROM node:10-slim

RUN apt-get update \
&& apt-get install -y git openssh-client libpng-dev \
&& npm --version \
&& npm install -g hexo-cli

WORKDIR /home/node/blog
29 changes: 29 additions & 0 deletions README.md
Expand Up @@ -9,7 +9,36 @@

This repository contains a source code of my blog [https://e.printstacktrace.blog](https://e.printstacktrace.blog)

## Running local blog using Docker

You can start Hexo server using Docker container with the following command:

```
$ ./hexo.sh server --config _config.yml,_config.local.yml
```

It will check if the docker image `eprinstacktraceblog:local` exists, and if not, it will generate one.

```
$ docker images eprintstacktraceblog:local
REPOSITORY TAG IMAGE ID CREATED SIZE
eprintstacktraceblog local eb7311f8fca5 2 minutes ago 268 MB
```

```
$ ./hexo.sh server --config _config.yml,_config.local.yml
INFO Config based on 2 files
[Browsersync] Access URLs:
----------------------------------
UI: http://localhost:3001
----------------------------------
UI External: http://localhost:3001
----------------------------------
INFO Start processing
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
```

![](https://i.imgur.com/SmwJVRyl.png)



9 changes: 9 additions & 0 deletions hexo.sh
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

DOCKER_IMAGE="eprintstacktraceblog:local"

if [[ "$(docker images -q $DOCKER_IMAGE 2> /dev/null)" == "" ]]; then
docker build -t $DOCKER_IMAGE .
fi

docker run --rm -u $(id -u) -p 4000:4000 -v $(pwd):/home/node/blog $DOCKER_IMAGE hexo "$@"

0 comments on commit 3147104

Please sign in to comment.