Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Dockerize of installation process #612

Closed
MirlanJA opened this issue Sep 12, 2020 · 3 comments
Closed

Dockerize of installation process #612

MirlanJA opened this issue Sep 12, 2020 · 3 comments

Comments

@MirlanJA
Copy link

Hi!
Can I customize Dockerfile so that I can answer questions during npm init nuxt-app?

@azrikahar
Copy link

Hi. I believe your intention is just to automate or autofill the questions right?

Then actually create-nuxt-app has an option called --answers which fits your use case here :) I found this out when I was browsing the source code and I'm not sure why it's not fully documented. I could be wrong, but I think it has to do with the questions being different across create-nuxt-app versions.

Example usage

What we normally do

  1. Run the following command to create a project called sample-app.

    yarn create nuxt-app sample-app
    # or
    npx create-nuxt-app sample-app
  2. We choose the following answers:

    create-nuxt-app v3.2.0
    ✨  Generating Nuxt.js project in sample-app
    ? Project name: sample-app
    ? Programming language: JavaScript
    ? Package manager: Yarn
    ? UI framework: Tailwind CSS
    ? Nuxt.js modules: Axios, Content
    ? Linting tools: ESLint, Prettier
    ? Testing framework: None
    ? Rendering mode: Universal (SSR / SSG)
    ? Deployment target: Static (Static/JAMStack hosting)
    ? Development tools: jsconfig.json (Recommended for VS Code if you're not using typescript)

Doing the same thing with the --answers option

To achieve the exact same configuration as we did above, here is the following command using --answers which takes in a json format of your selections:

yarn create nuxt-app sample-app --answers '{"name":"sample-app","language":["js"],"pm":"npm","ui":"tailwind","features":["axios","content"],"linter":["eslint","prettier"],"test":"none","mode":"universal","target":"static","devTools":["jsconfig.json"]}'
# or 
npx create-nuxt-app sample-app --answers '{"name":"sample-app","language":["js"],"pm":"npm","ui":"tailwind","features":["axios","content"],"linter":["eslint","prettier"],"test":"none","mode":"universal","target":"static","devTools":["jsconfig.json"]}'

Remember to change the sample-app in the command to your own project name. Also note that sample-app appears 2 times per command. first one after nuxt-app, second one inside the json string.


You can try out this command directly in your own terminal and check whether it works or not. Then for your Dockerfile use case, I think you'll just need to create this command string and pass in environment variables if you want to make it customizable.

@MirlanJA
Copy link
Author

Excellent! thank you! soon I make repository with docker configure for nuxt app

@azrikahar
Copy link

You're welcome. You might also be interested in the current open PR #581 which adds docker option to the CLI directly and generate the Dockerfile & docker-compose.yml files for you :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants