Merge pull request #207 from creative-commoners/feature/docker

Add docker support for development environment
This commit is contained in:
Serge Latyntsev 2019-11-20 16:42:29 +13:00 committed by GitHub
commit 4fa94b50d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 2 deletions

View File

@ -23,12 +23,24 @@ stored in
To set up a local instance of [doc.silverstripe.org](https://github.com/silverstripe/doc.silverstripe.org):
* Install [Gatsby CLI](https://gatsbyjs.com)
* Clone this repository to an empty directory
```
git clone https://github.com/silverstripe/doc.silverstripe.org path/to/ssdocs
```
### Docker install
No local NodeJS nor gatsby-cli is required for this option.
* Make sure docker and docker-compose are installed and docker daemon is running
* Simply use `./docker/run` to run gatsby commands
- `./docker/run build` would be equal to run `gatsby build` within a container
- `./docker/run develop -p 8000` would run `gatsby develop -p 8000` within a container.
### Native install
* Install [Gatsby CLI](https://gatsbyjs.com)
## Building
To test a static build of the site, first create a production environment file.
@ -55,7 +67,7 @@ From within `path/to/ssdocs`, run the command
gatsby develop
```
to instantiate a development server. This will consume all of the markdown files in both major release
branches and allow you to browse the documentation site on `http://localhost:8000` by default
branches and allow you to browse the documentation site on `http://localhost:8000` by default
(see the [Gatsby docs](https://www.gatsbyjs.org/docs/) for instructions on customising the port).
## Authoring

3
docker/Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM node:12
RUN yarn global add gatsby-cli

15
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,15 @@
version: '3.7'
x-entrypoint: &entry
- /bin/bash
- /app/docker/entrypoint.sh
services:
gatsby:
build:
context: .
working_dir: /app
network_mode: "host"
volumes:
- '..:/app'
entrypoint: *entry

9
docker/entrypoint.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
cd /app;
if [[ ! -d "/app/node_modules" ]] ; then
yarn;
fi;
gatsby $@

3
docker/run Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cd $(dirname $0) && docker-compose run -u $(id -u) --rm gatsby $@