Docker-compose Nuxtjs

Docker-compose Nuxtjs

If you can already run your app in Docker, you wont gain much from Docker Compose, unless you need to run multiple containers. As stated in Overview of Docker Compose, Compose is a tool for defining and running multi-container Docker applications.

Based on the linked tutorial, docker-compose.yaml could look something like this:

version: 3

    image: nuxtjs-tutorial:latest
      - 3000:3000
      - NUXT_HOST=
      - NUXT_PORT=3000

The environment variables do not need to be set from the Compose file, this is just an example. Compose allows you to set many options, as described in the Compose file reference. For example, you could run the app in Compose using entrypoint instead of CMD in Dockerfile. Or you could only copy package.json in Dockerfile, build the dependencies during image build, and mount your code using volumes.

I found multiple example references online, but I woulnt consider any of them best practice. Best to read the official Documentation.

Regarding your update, based on the Dockerfile in the tutorial, you do not even need the build and command entries, only image and ports. But as I said above, you can set many options from Compose, best described in official documentation.

Docker-compose Nuxtjs

Leave a Reply

Your email address will not be published.