Add docker related file to basic example

This commit is contained in:
hiluluke 2018-08-30 21:41:19 +08:00
parent 421d9b03de
commit 6dcd24ec8d
4 changed files with 60 additions and 13 deletions

View file

@ -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"]

View file

@ -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

View file

@ -0,0 +1,2 @@
*/node_modules
*.log

View file

@ -155,20 +155,34 @@ if (feature === 'translations') {
exampleSiteCreated = true; exampleSiteCreated = true;
blogCreated = true; blogCreated = true;
} }
// copy .gitignore file
let gitignoreName = '.gitignore'; const copyFileOutWebsiteFolder = (fileNameFrom, isHide) => {
if (fs.existsSync(`${CWD}/../.gitignore`)) { let fileNameTo = isHide ? `.${fileNameFrom}` : fileNameFrom;
gitignoreName = '.gitignore-example-from-docusaurus'; if (fs.existsSync(`${CWD}/../${fileNameTo}`)) {
fileNameTo = `${fileNameTo}-example-from-docusaurus`;
console.log( console.log(
`${chalk.yellow('.gitignore already exists')} in ${chalk.yellow( `${chalk.yellow(fileNameTo + ' already exists')} in ${chalk.yellow(
CWD CWD
)}. Creating an example gitignore file for you to copy from if desired.\n` )}. Creating an example ${fileNameTo} file for you to copy from if desired.\n`
); );
} }
fs.copySync( fs.copySync(
path.join(folder, 'gitignore'), path.join(folder, fileNameFrom),
path.join(CWD, `/../${gitignoreName}`) path.join(CWD, `/../${fileNameTo}`)
); );
};
// 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 // copy other files
const files = glob.sync(`${folder}/**/*`); const files = glob.sync(`${folder}/**/*`);
@ -179,6 +193,9 @@ if (feature === 'translations') {
const containingFolder = path.basename(path.dirname(file)); const containingFolder = path.basename(path.dirname(file));
if ( if (
path.basename(file) === 'gitignore' || path.basename(file) === 'gitignore' ||
path.basename(file) === 'Dockerfile' ||
path.basename(file) === 'docker-compose.yml' ||
path.basename(file) === 'dockerignore' ||
containingFolder === 'blog-examples-from-docusaurus' || containingFolder === 'blog-examples-from-docusaurus' ||
containingFolder === 'docs-examples-from-docusaurus' containingFolder === 'docs-examples-from-docusaurus'
) { ) {