mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
Add docker related file to basic example
This commit is contained in:
parent
421d9b03de
commit
6dcd24ec8d
4 changed files with 60 additions and 13 deletions
10
examples/basics/Dockerfile
Normal file
10
examples/basics/Dockerfile
Normal 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"]
|
18
examples/basics/docker-compose.yml
Normal file
18
examples/basics/docker-compose.yml
Normal 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
|
2
examples/basics/dockerignore
Normal file
2
examples/basics/dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
*/node_modules
|
||||
*.log
|
|
@ -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';
|
||||
|
||||
const copyFileOutWebsiteFolder = (fileNameFrom, isHide) => {
|
||||
let fileNameTo = isHide ? `.${fileNameFrom}` : fileNameFrom;
|
||||
if (fs.existsSync(`${CWD}/../${fileNameTo}`)) {
|
||||
fileNameTo = `${fileNameTo}-example-from-docusaurus`;
|
||||
console.log(
|
||||
`${chalk.yellow('.gitignore already exists')} in ${chalk.yellow(
|
||||
`${chalk.yellow(fileNameTo + ' already exists')} in ${chalk.yellow(
|
||||
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(
|
||||
path.join(folder, 'gitignore'),
|
||||
path.join(CWD, `/../${gitignoreName}`)
|
||||
path.join(folder, fileNameFrom),
|
||||
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
|
||||
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'
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue