Skip to content

Commit

Permalink
Add docker related file to basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
wszgxa committed Sep 1, 2018
1 parent 421d9b0 commit 4eb3ec9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 13 deletions.
10 changes: 10 additions & 0 deletions examples/basics/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
18 changes: 18 additions & 0 deletions examples/basics/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions examples/basics/dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/node_modules
*.log
43 changes: 30 additions & 13 deletions lib/copy-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/**/*`);
Expand All @@ -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'
) {
Expand Down

0 comments on commit 4eb3ec9

Please sign in to comment.