diff --git a/examples/basics/Dockerfile b/examples/basics/Dockerfile new file mode 100644 index 0000000000..d369844d5b --- /dev/null +++ b/examples/basics/Dockerfile @@ -0,0 +1,10 @@ +FROM node:8.11.4 + +WORKDIR /app/website + +EXPOSE 3000 35729 +COPY ./docs /app/docs +COPY ./website /app/website +RUN yarn install + +CMD ["yarn", "start"] diff --git a/examples/basics/docker-compose.yml b/examples/basics/docker-compose.yml new file mode 100644 index 0000000000..6711192ae1 --- /dev/null +++ b/examples/basics/docker-compose.yml @@ -0,0 +1,18 @@ +version: "3" + +services: + docusaurus: + build: . + ports: + - 3000:3000 + - 35729:35729 + volumes: + - ./docs:/app/docs + - ./website/blog:/app/website/blog + - ./website/core:/app/website/core + - ./website/i18n:/app/website/i18n + - ./website/pages:/app/website/pages + - ./website/static:/app/website/static + - ./website/sidebars.json:/app/website/sidebars.json + - ./website/siteConfig.js:/app/website/siteConfig.js + working_dir: /app/website diff --git a/examples/basics/dockerignore b/examples/basics/dockerignore new file mode 100644 index 0000000000..27d2dae2b4 --- /dev/null +++ b/examples/basics/dockerignore @@ -0,0 +1,2 @@ +*/node_modules +*.log diff --git a/lib/copy-examples.js b/lib/copy-examples.js index 1247b2c643..49381eec55 100755 --- a/lib/copy-examples.js +++ b/lib/copy-examples.js @@ -155,20 +155,34 @@ if (feature === 'translations') { exampleSiteCreated = true; blogCreated = true; } - // copy .gitignore file - let gitignoreName = '.gitignore'; - if (fs.existsSync(`${CWD}/../.gitignore`)) { - gitignoreName = '.gitignore-example-from-docusaurus'; - console.log( - `${chalk.yellow('.gitignore already exists')} in ${chalk.yellow( - CWD - )}. Creating an example gitignore file for you to copy from if desired.\n` + + const copyFileOutWebsiteFolder = (fileNameFrom, isHide) => { + let fileNameTo = isHide ? `.${fileNameFrom}` : fileNameFrom; + if (fs.existsSync(`${CWD}/../${fileNameTo}`)) { + fileNameTo = `${fileNameTo}-example-from-docusaurus`; + console.log( + `${chalk.yellow(fileNameTo + ' already exists')} in ${chalk.yellow( + CWD + )}. Creating an example ${fileNameTo} file for you to copy from if desired.\n` + ); + } + fs.copySync( + path.join(folder, fileNameFrom), + path.join(CWD, `/../${fileNameTo}`) ); - } - fs.copySync( - path.join(folder, 'gitignore'), - path.join(CWD, `/../${gitignoreName}`) - ); + }; + + // copy .gitignore file + copyFileOutWebsiteFolder('gitignore', true); + + // copy Dockerfile file + copyFileOutWebsiteFolder('Dockerfile', false); + + // copy docker-compose.yml file + copyFileOutWebsiteFolder('docker-compose.yml', false); + + // copy .dockerignore file + copyFileOutWebsiteFolder('dockerignore', true); // copy other files const files = glob.sync(`${folder}/**/*`); @@ -179,6 +193,9 @@ if (feature === 'translations') { const containingFolder = path.basename(path.dirname(file)); if ( path.basename(file) === 'gitignore' || + path.basename(file) === 'Dockerfile' || + path.basename(file) === 'docker-compose.yml' || + path.basename(file) === 'dockerignore' || containingFolder === 'blog-examples-from-docusaurus' || containingFolder === 'docs-examples-from-docusaurus' ) {