From 8609a09f4b2278ac5784d866971b82967f5d2f3e Mon Sep 17 00:00:00 2001 From: Serge Latyntcev Date: Wed, 20 Nov 2019 12:03:17 +1300 Subject: [PATCH] Add docker support for development environment --- README.md | 16 ++++++++++++++-- docker/Dockerfile | 3 +++ docker/docker-compose.yml | 15 +++++++++++++++ docker/entrypoint.sh | 9 +++++++++ docker/run | 3 +++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docker/Dockerfile create mode 100644 docker/docker-compose.yml create mode 100644 docker/entrypoint.sh create mode 100755 docker/run diff --git a/README.md b/README.md index aae69d4..80ed7af 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..7a3853f --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,3 @@ +FROM node:12 + +RUN yarn global add gatsby-cli \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..2f26b4f --- /dev/null +++ b/docker/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..c9dd24a --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd /app; + +if [[ ! -d "/app/node_modules" ]] ; then + yarn; +fi; + +gatsby $@ diff --git a/docker/run b/docker/run new file mode 100755 index 0000000..d8f62e9 --- /dev/null +++ b/docker/run @@ -0,0 +1,3 @@ +#!/bin/bash + +cd $(dirname $0) && docker-compose run -u $(id -u) --rm gatsby $@ \ No newline at end of file