I am creating my first Nuxtjs app but I want to use Docker-compose. I was able to Dockerize my application following this tutorial: https://dockerize.io/guides/docker-nuxtjs-guide
Now I want to bring it to the next level using compose but I'm not too familiar with Serverside-rendering and how this could affect my docker-compose file. Unfortunately I cannot find any guide on how to use docker-compose on NuxtJS apps. Do you know where I can find a good guide for it? Thanks.
UPDATE: I created a docker-compose.yml file and is working but still I can't find any guide to see if it is a good yml file (best practices etc.)
version: '3'
services:
web:
build: .
command: npm run dev
ports:
- '3000:3000'
If you can already run your app in Docker, you won't 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: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 ofCMD
inDockerfile
. Or you could only copypackage.json
inDockerfile
, build the dependencies during image build, and mount your code usingvolumes
.I found multiple example references online, but I wouln't 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 thebuild
andcommand
entries, onlyimage
andports
. But as I said above, you can set many options from Compose, best described in official documentation.